I'm using Firebase with the Google authentication provider.
When using Google OAuth in other applications, I'm able configure authentication to be restricted to specific domains.
The Google OpenID Connect documentation details the "hd" parameter which is used for this functionality. https://developers.google.com/identity/protocols/OpenIDConnect#hd-param
How can this be configured for Firebase?
In the Firebase console, open the Auth section. On the Sign in method tab, enable the Google sign-in method and click Save.
Firebase Authentication integrates tightly with other Firebase services, and it leverages industry standards like OAuth 2.0 and OpenID Connect, so it can be easily integrated with your custom backend.
With the new setCustomParameters function, you can add the hd
parameter
var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('email');
provider.setCustomParameters({
'hd': 'uw.edu'
});
firebase.auth().signInWithRedirect(provider);
Here is the API Doc https://firebase.google.com/docs/reference/js/firebase.auth.GoogleAuthProvider#setCustomParameters
Requires at least Firebase Version 3.5.0 - October 14, 2016. https://firebase.google.com/support/release-notes/js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With