Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit Firebase Google OAuth Authentication to specific users

I'm using Firebase to handle my Google OAuth login for my website. Does anyone knew how to restrict the users who have access to the application? For example, I only want [email protected], [email protected], and [email protected] to successfully be able to log in via google to my application.

I wasn't sure if this was a Firebase or Google question, but any help would be much appreciated.

like image 722
Arun Kalyanaraman Avatar asked Feb 10 '15 00:02

Arun Kalyanaraman


People also ask

How do I get all users from Firebase authentication?

If you want to view a list of users that has registered thru Firebase Auth, you may view them in https://console.firebase.google.com/ then go to your project and select authentication , in the Users list is all the users that have registered thru Firebase Auth.

Can I use Firebase for authentication only?

You can use Firebase Authentication to allow users to sign in to your app using one or more sign-in methods, including email address and password sign-in, and federated identity providers such as Google Sign-in and Facebook Login.


2 Answers

Firebase's authentication handles only that: the authentication of users through any of the mechanisms you enable. Whether those users have access to your data is called authorization and it is handled through the security rules of your Firebase.

So:

  • Authentication allows the user to identify him/herself with your application. See Firebase's documentation on authentication (for JavaScript/Web, but it exists for all supported platforms).
  • Authorization limits read/write access to your data to specific users, based on their authentication. See Firebase's documentation on its security rules.

Limiting access to your data to specific email addresses is certainly possible. I recommend that you read Firebase's documentation on the its security rules and try to make it work based on that. If you have any problems, post what you've tried and we'll be able to help you better.

like image 82
Frank van Puffelen Avatar answered Oct 03 '22 08:10

Frank van Puffelen


These rules will allow anybody to login, but only the listed email addresses to read or write data:

{
  "rules": {
    ".read":  "auth.email == '[email protected]' || 
               auth.email == '[email protected]' || 
               auth.email == '[email protected]'",

    ".write": "auth.email == '[email protected]' || 
               auth.email == '[email protected]' || 
               auth.email == '[email protected]'"
  }
}
like image 25
paul Avatar answered Oct 03 '22 07:10

paul