Reputation: 2161
How do we check what the values are in firebase security rules? I have some rules that are failing but they shouldn't be so I need to check what is actually happening in there. Is there a console.log() or console.print() ability?
match /test/{testId} {
//console.log(resource.data.relationships.keys());
allow read: if resource.data.relationships.keys().hasAll([request.auth.uid]);
allow write: if userIsAuthenticated();
}
Upvotes: 1
Views: 1373
Reputation: 598563
If you're using the Firestore emulator, what you're looking for is the debug
function, which:
Note:
debug
function blocks are only executed by the Security Rules engine in the Firestore emulator, part of the Firebase Emulator Suite. Thedebug
function has no effect in production.
You can use it anywhere in your rule value, so all of these are valid:
if debug(resource.data.relationships.keys().hasAll([request.auth.uid]))
if resource.data.relationships.keys().hasAll([debug(request.auth.uid)])
I'm curious if this is also valid:
if debug(resource.data.relationships.keys()).hasAll([request.auth.uid])
Let me know if you've given that a try.
Upvotes: 4