0

I'm currently developing an app for my university using Ionic 2 and Firebase. So, the problem is how to restrict user from signing up unless they're using specific domain eg.(@ukm.edu.my)? It's for my university, I don't want anyone else to use this app. So, anyone without that specific email domain can't sign up for my app.

From what I've read, Firebase database rules only affect authorization. So, how to setup rules for authentication?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
AsyR
  • 3
  • 3

1 Answers1

2

You can't do it with what Firebase provides.

You can only restrict access to the database adding a rule stating that users with email in a specific domain can access it.

{
  "rules": {
    ".read": "auth.token.email.endsWith('@example.com')",
    ".write": "auth.token.email.endsWith('@example.com')",
  }
}
Michał Pietraszko
  • 5,666
  • 3
  • 21
  • 27
  • So, there's no other way I can prevent other people from signing up my apps if I am using firebase? – AsyR Jul 08 '17 at 13:19
  • You can't limit people from signing in with Firebase Authentication. But you can prevent them from accessing data they're not authorized for. – Frank van Puffelen Jul 08 '17 at 14:20
  • See some of these previous answers: https://stackoverflow.com/a/17728534/209103, https://stackoverflow.com/a/21834842/209103, https://stackoverflow.com/a/24064712/209103, https://stackoverflow.com/a/38357717/209103, https://stackoverflow.com/a/43547921/209103, https://stackoverflow.com/a/38019847/209103 – Frank van Puffelen Jul 08 '17 at 14:25
  • Thank you @FrankvanPuffelen – AsyR Jul 09 '17 at 00:59
  • I want the same rule in my app sign-up but Firebase updated some syntax of rule with `match` keyword do you have any idea how to write above rule in latest firebase rules syntax? – CodeChanger Aug 08 '19 at 08:50