The simulator allows read/write to Posts key, but the results are correct for the Users key rules. Each post under Posts has a uid value representing a user in Users key.
Are my rules wrong or is the simulator wrong? Be gentle, I'm new to Firebase. :)
Two equals:
Redacted Data view:
Try changing your rules to check that a uid
child exists. For example:
".read": "data.child('uid').exists() && data.child('uid').val() === auth.uid"
Based on a quick test, I think what is occuring is that when a uid
child does not exist, the evaluation of data.child('uid').val()
fails and is handled by assigning it a value of false. Similarly, because the user is not authenticated, auth
is null and auth.uid
also evaluates to false. So your rule effectively becomes ".read": "false === false"
, which is true.
When I first simulated a read using your rule and I did not have a uid
child in my database under /posts/1
, the read was granted, as you reported. When I added a uid
child, it was not granted.