0
votes

I am learning about Firebase Database and am trying to set up security rules. To start, I am creating very permissive rules with something like this:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/users/{user_id} {
    allow read, write: if true;
  }
}

I found the Rules Playground tool in the Firebase Console and attempt to get a document:

enter image description here

But when I click Run, I get "Simulated read denied".

What am I missing? Why doesn't my rule allow the read? What do I need to change to allow reads and writes?

1

1 Answers

2
votes

Your rules are just incorrect. It look like you edited down the path too far. Your outer match should always be "/databases/{database}/documents". The whole thing should look like this if you want to allow full access to the users collection:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{user_id} {
      allow read, write: if true;
    }
  }
}