user13512643
user13512643

Reputation:

Checking for a substring in a Firebase Firestore security rule

I already worked through the documentation of Googles FireBase security rules, but I am struggling to get a verification done, where the eMail-address of the FireBase Authtoken is checked if it is part of a domain (like "*@test.de") before reading the FireStore-database is allowed.

I tried:

auth.token.email.matches(/.*@test.de$/)

I copied it from https://firebase.google.com/docs/reference/security/database , but it doesn't seem to work for FireStore.

Upvotes: 1

Views: 837

Answers (1)

Kuhlemann
Kuhlemann

Reputation: 3426

This is quite simple if you know the correct syntax.

You can do it like this:

  allow read: if request.auth.token.email.matches('.*@test[.]de');

Upvotes: 4

Related Questions