Arun Kalyanaraman
Arun Kalyanaraman

Reputation: 648

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.

Upvotes: 17

Views: 9632

Answers (2)

Frank van Puffelen
Frank van Puffelen

Reputation: 599776

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:

Limiting access to your data to specific email addresses is certainly possible. I recommend that you read Firebase's documentation on 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.

Upvotes: 17

paul
paul

Reputation: 22011

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]'"
  }
}

Upvotes: 9

Related Questions