Set a security rule firebase based on a users oauth email -
is there way securely email oauthed in in security rule.
ideally wanted create rule like:
{ ".read": "auth.google.email.matches(/@example.com$/)" ".write": "auth.google.email.matches(/@example.com$/)" }
so entire application, or section of application secured email address suffix. easier of way manage application because users given access based on company email have, or nothing.
alternatively theres way save users email address database cant write believe achieve similar process.
the auth. properties of oauth providers not available in security rules. per documentation on auth variable:
the predefined
auth
variable null before authentication takes place. once user authenticated firebase login's auth method, contain following attributes:provider authentication method used ("password", "anonymous", "facebook", "github", "google", or "twitter").
uid unique user id, guaranteed unique across providers.
so cannot secure data based on email address, unless involve server provide email domain in secure way.
once involve server, can either:
- verify email address , store verified email address in database. can access in security rules
root.child('users').child(auth.uid).child('emaildomain').val()
- mint own tokens include email domain, becomes available in the
auth
variable in security rulesauth.emaildomain
.
Comments
Post a Comment