Open the published rules in the console
In the Firebase console, select your project, choose Realtime Database, then click Rules. Read what is published now, not what you remember pasting.
Docs: firebase.google.com →
Search the rules for a read grant at a shallow node
Look for ".read": true, or a read condition that does not depend on auth, at the root or on a parent of sessions, players and presence. A grant at a parent covers the children below it.
{
"rules": {
".read": true,
".write": true
}
}
Docs: firebase.google.com →
Reproduce the public read in the Rules Playground
Open the Rules Playground from the Rules editor, set it to simulate a read, and click Run for each of the three paths without signing in. If the read succeeds, the rules are the cause, not the client code.
Docs: firebase.google.com →
Replace the blanket grant with per-user rules
Remove the root ".read" and ".write" and scope each node to the signed-in owner using a $uid capture variable. This assumes these nodes are keyed by user ID. Adjust the key if yours are not.
{
"rules": {
"players": {
"$uid": {
".read": "auth.uid === $uid",
".write": "auth.uid === $uid"
}
},
"sessions": {
"$uid": {
".read": "auth.uid === $uid",
".write": "auth.uid === $uid"
}
},
"presence": {
"$uid": {
".read": "auth.uid === $uid",
".write": "auth.uid === $uid"
}
}
}
}
Docs: firebase.google.com →
Grant shared reads at the narrowest path that needs them
If other players must see a node such as presence, put the read rule on that child path, not on a parent, because shallower rules override deeper ones. Keep writes tied to auth.uid === $uid. Treat a sign-in-only read as a deliberate decision, since the docs advise against leaving data open to any signed-in user.
Docs: firebase.google.com →
Publish, then deploy from the same source
Click Publish in the console once the Playground results match what you expect. If the project uses the CLI, put the same rules in the .rules file and deploy it, so the next deploy does not restore the open rule.
firebase deploy --only database
Docs: firebase.google.com →