I still see devs (even pros) leaving this in their Firestore rules during testing:
// β PLEASE DON'T
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
It works. Itβs fast.
It also means anyone on the internet can read, write, delete, or overwrite anything in your database β no auth needed.
β Better: Restrict by request.auth != null and, if possible, user-specific ownership.
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}
This way:
Only logged-in users can access data
They can only touch their own documents
π§ Takeaway:
> βYour Firebase rules are your databaseβs last line of defense β treat them like production code.β
If this saved your data from getting roasted, maybe buy me a coffee to keep the security tips flowing:
π buymeacoffee.com/ejjat β
#firebase #firestore #securitytips #dailydev #buymeacoffee
