To use external identities with Identity-Aware Proxy (IAP), your app needs a sign-in page. IAP will redirect users to this page to authenticate before they can access secure resources.
This article shows you how to build an authentication page using FirebaseUI, an open-source JavaScript library. FirebaseUI provides customizable elements that help reduce boilerplate code, and handles the flows for signing in users with a wide range of identity providers.
To get started faster, let IAP host the UI for you. This lets you try external identities without writing any additional code. For more advanced scenarios, you can also build your own sign-in page from scratch. This option is more complex, but gives you full control over the authentication flow and user experience.
Before you begin
Enable external identities, and select the I'll provide my own UI option during setup.
Installing the libraries
Install the gcip-iap, firebase, and firebaseui libraries. The
gcip-iap module abstracts communications between your app,
IAP, and Identity Platform. The firebase and firebaseui libraries provide the building blocks for your authentication UI.
npm install firebase --save
npm install firebaseui --save
npm install gcip-iap --save
Note that the gcip-iap module is not available using CDN.
You can then import the modules in your source files. Use the correct imports for your SDK version:
gcip-iap v0.1.4 or earlier
// Import firebase modules.
import * as firebase from "firebase/app";
import "firebase/auth";
// Import firebaseui module.
import * as firebaseui from 'firebaseui'
// Import gcip-iap module.
import * as ciap from 'gcip-iap';
gcip-iap v1.0.0 or later
Starting with version v1.0.0, gcip-iap requires the firebase v9 peer dependency or greater.
If you are migrating to gcip-iap v1.0.0 or above, complete the following
actions:
- Update the
firebaseandfirebaseuiversions in yourpackage.jsonfile to v9.6.0+ and v6.0.0+ respectively. - Update the
firebaseimport statements as follows:
// Import firebase modules.
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
// Import firebaseui module.
import * as firebaseui from 'firebaseui'
// Import gcip-iap module.
No additional code changes are needed.
For additional installation options, including using localized versions of the libraries, refer to the instructions on GitHub.
Configuring your application
FirebaseUI uses a configuration object that specifies the tenants and providers to use for authentication. A full configuration can be very long, and might look something like this:
// The project configuration.
const configs = {
// Configuration for project identified by API key API_KEY1.
API_KEY1: {
authDomain: 'project-id1.firebaseapp.com',
// Decide whether to ask user for identifier to figure out
// what tenant to select or whether to present all the tenants to select from.
displayMode: 'optionFirst', // Or identifierFirst
// The terms of service URL and privacy policy URL for the page
// where the user select tenant or enter email for tenant/provider
// matching.
tosUrl: 'http://localhost/tos'