How can I custom authentication that only the email with certain domain can register?

4,936 views
Skip to first unread message

苗润坤

unread,
Jul 15, 2016, 11:26:46 AM7/15/16
to Firebase Google Group
I'm currently using Firebase to build my first app, but I want to limit my target user within my university. So, I'm thinking about let only the people with university email address can register my app, how can I achieve this?

Joe White

unread,
Jul 15, 2016, 2:28:02 PM7/15/16
to Firebase Google Group
The simplest way is to checkthe eMail that you obtain from your user and only begin a Firebase authentication if the eMail comes from a domain that you want to allow.  

You could also look at whether you want to use Firebase realtime database, and add security rules there that check for an "allowed" domain in the eMail address.

Jacob Wenger

unread,
Jul 18, 2016, 1:35:17 AM7/18/16
to fireba...@googlegroups.com
Hey there,

You cannot prevent sign ups based on email address, but you can prevent users from accessing resources like the Realtime Database and Storage via Security Rules (docs here and here). Your rule would look like this to limit read and write access to only @gmail.com email addresses:

{
  "rules": {
    ".read": "auth.token.email.endsWith('@gmail.com')",
    ".write": "auth.token.email.endsWith('@gmail.com')"
  }
}

Hope that helps,
Jacob

This message (and any associated files) may contain VelociKey confidential and/or privileged information. If you are not the intended recipient or authorized to receive this for the intended recipient, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by sending a reply e-mail and delete this message. Thank you for your cooperation.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/011d6ab2-01a2-43a3-b9a2-eec38a1363a4%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Luke Freeman

unread,
Jul 18, 2016, 5:22:46 PM7/18/16
to Firebase Google Group
Any chance / place I can file this as a feature request?

Jacob Wenger

unread,
Jul 22, 2016, 6:04:57 PM7/22/16
to fireba...@googlegroups.com
I've forward this request on to the auth team. You can and should use Security Rules to achieve this behavior for the existing SDKs.

Cheers,
Jacob

Reply all
Reply to author
Forward
0 new messages