Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Auth - list of users by Custom Claims

We're using Custom Claims in Firebase Auth to manage access in Firebase and allow custom UI experience.

We're now working on the User Admin part and we can't find a way to retrieve users by the custom claims.

For example, a user belongs to an organisation and have different access level - admin or user. We need to allow the organisation's admin to see all their organisation's users.

We'd like to avoid using a separate database to manage organisation users to not double up the data.

Is it possible? Can we retrieve all Auth users while filtering them by specific Custom Claim?

Thanks!

like image 402
xims Avatar asked Oct 20 '18 04:10

xims


People also ask

How do I get all users from Firebase authentication?

If you want to view a list of users that has registered thru Firebase Auth, you may view them in https://console.firebase.google.com/ then go to your project and select authentication , in the Users list is all the users that have registered thru Firebase Auth.

How can I get user details from Firebase?

If the user login with a custom "email/password" you don't know anything else about that user (apart from the unique user id). If a user login with Facebook, or with Google sign in, you can get other information like the profile picture url. It is explained here: firebase.google.com/docs/auth/android/… .

What does Firebase auth () CurrentUser return?

If a user isn't signed in, CurrentUser returns null. Note: CurrentUser might also return null because the auth object has not finished initializing.

What does GetAuth do in Firebase?

GetAuth. Returns the FirebaseAuth object for an App. Creates the FirebaseAuth if required.


1 Answers

There is no built-in API to get a list of all users that have a specific claim.

There is an API to get a list of all users in the Admin SDK. So you could use that and then filter the users that have the claim you're looking for.

But performance of this will not be spectacular. So if listing all users with a specific claim is a common use-case for your app, you'll want to reconsider your concern about using an additional place to store the data. Duplicating data to achieve (well performing) use-cases is quite common in NoSQL.

like image 173
Frank van Puffelen Avatar answered Nov 02 '22 00:11

Frank van Puffelen