I couldn’t find it in the docs but is there a way to define a group of users and use that group to grant access to different locations, rather than granting access to individual users?
Regards,
LT
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no explicit support for "groups" in Firebase, because you can represent them yourself quite easily. Here are two options, depending on your situation.
Storing group information in firebase.
The following data could be used to represent 2 groups (‘alpha’ and ‘beta’) and 3 pieces of protected data (‘thing1’, ‘thing2’, and ‘thing3’)
Then we can use the following rules to enforce security:
So then if I’m authenticated with { id: ‘sally’ } as my auth object, I’ll have access to thing1 and thing3, but not thing2.
Storing group information in the auth token.
If you’re generating your own auth tokens and you know what groups a user is in at the time they auth, you could store the list of groups in the auth token you generate. For example, when you generate the auth token for user ‘fred’, include "{ id: ‘fred’, groups: { alpha: true, beta: true } }"
And then you can enforce group membership with: