Reputation: 1703
My app can users with roles OWNER
, ADMIN
or USER
, in decreasing privileges. An OWNER
can create ADMIN
s and USER
s. An ADMIN
can create USER
s. A USER
cannot create anything. There can be multiple OWNER
s, ADMIN
s and USER
s. Once the users have been created with relevant claims, this all works fine.
However, I do not understand how to create OWNER
s in the first place. Do I create a cloud function that, when called, would create a new OWNER
? What if someone can call it directly and create new OWNER
s? How do I accomplish this?
Upvotes: 1
Views: 230
Reputation: 50840
I just run a NodeJS script locally to add that one time role to a single user. You don't necessarily need Cloud Function but using it will save some time in setting up service account. Just use the Functions emulator locally by writing a one time function.
I have a detailed answer on that here: Firebase Custom Claims without Cloud functions
Once you add the OWNER
claim, then you can deploy the same function to add claims to other users but just add a simple if
statement to check if the caller has OWNER
role or any role that can add the relevant roles.
Upvotes: 1