Using the firestore online security simulation with custom claims results in an error, but it works perfectly when deployed (while actually handling real requests). The error is:
Error: simulator.rules line [5], column [23]. Property admin is undefined on object.
I have confirmed that the user actually have the claim (by the admin SDK and by using the application I'm adding the rules to).
match /{document=**} {
allow write: if request.auth.token.admin;
allow read;
}
Is this expected? Is the simulator broken or am I missing something? Not being able to use the simulator will be hard as I expect to use a few custom claims in my application.
The rules simulator doesn't run with a real user from Firebase Authentication, but runs with the user you define within the simulator itself in the bottom left section of your screenshot.
So you'll need to specify the admin
claim in the rules playground by selecting the Custom provider, and then editing the Auth token payload to include a token.admin
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With