Prompt
My Firebase auth works but my database rules are a mess
Latest observation
Nov 4, 2026
OpenAI APIWeb search: off
Got it — this is usually fixable pretty quickly.
If your Firebase Auth works but your Firestore / Realtime Database rules are a mess, the best path is:
- Figure out which database you’re using
- Cloud Firestore or Realtime Database
- Define the access model
- Who can read?
- Who can write?
- Is data user-owned?
- Are there admin users?
- Rewrite rules from a simple baseline
- Test with the Rules Playground / Emulator
- Tighten gradually
Good starting point
If you use Firestore
A common safe pattern for user-owned data:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}
If you use Realtime Database
{
"rules": {
"users": {
"$userId": {
".read": "auth != null && auth.uid === $userId",
".write": "auth != null && auth.uid === $userId"
}
}
}
}
Common mistakes
allow read, write: if true;left in production- Trying to use
request.auth.token.emailfor authorization instead ofuid - Mixing admin logic into client rules without custom claims
- Nesting rules too deeply without clear ownership
- Allowing broad collection access when only document-level access is needed
Best practice
Use:
uid-based ownership for most user data- custom claims for admin/moderator roles
- separate collections/paths for public vs private data
If you want, I can help you clean them up
Paste:
- your current rules
- whether you use Firestore or Realtime Database
- what data you want public/private
- whether you have roles like admin/user
And I’ll rewrite your rules into something sane and secure.