I'm just getting started with Firebase, and notice that there are a lot of tutorials/docs that instruct you to put the following into the rules for your database:
{
"rules": {
"$uid": {
".write": "$uid === auth.uid",
".read": "$uid === auth.uid"
}
}
}
However, there seems to be a new version of this code out, version 2. I was wondering if the code I have above, which is outdated and version 1 (I guess), is essentially equivalent to this code:
// Allow read/write access on all documents to any user signed in to the application
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}
which comes from the google firebase docs (https://firebase.google.com/docs/firestore/security/get-started)
Thanks
You're showing rules from two different products that aren't directly related to each other.
Your first sample is for Firebase Realtime Datbase. That JSON-based rules language hasn't changed in years.
Your second sample is for Firestore. That's a completely different security rules language that's a little bit similar to, but not at all the same as, Firebase Realtime Database.
The rules "version 2" you're referring to is for Firestore only. It changes the behavior of a couple aspects of the language, and that's all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With