All the users for firebase project are authenticated using Phone provider.
I am setting custom claim for all users using C# as follows -
var claims = new Dictionary<string, object>()
{
{ "admin", true },
};
var pagedEnumerable = FirebaseAuth.DefaultInstance.ListUsersAsync(null);
var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator();
while (responses.MoveNextAsync().Result)
{
ExportedUserRecords response = responses.Current;
foreach (ExportedUserRecord user in response.Users)
{
FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync(user.Uid, claims);
}
}
In the firebase realtime database I have following nodes -
{
"Configuration" : {
"Sync" : "XYZ"
},
"adminContent" : {
"key" : "val1"
}
}
I am trying to configure database access rules using custom claim as -
{
"rules": {
"adminContent": {
".read": "auth.token.admin === true",
".write": "auth.token.admin === true"
}
}
}
I am trying to use the rule playground to verify read access to adminContent node and getting error as -
The result pop up reads as -
Request - Type read Location /adminContent Data null Auth { "provider": "anonymous", "uid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } Admin false
Response - READ Denied Line 5 (/adminContent) read: "auth.token.admin === true"
Using C# code I have verified that admin custom claim exists on the user.
Will any one pls help to fix this error?