skip to Main Content

I have added some rules to the Firestore database in the firebase console and everything works fine with the cloud.

When I deploy rules in the emulator, they are ignored and I get the error message "Missing or insufficient permissions".

The rules allow access to all data:

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

In the Emulator UI, there seems to be no indication of what rules it applies. Is there anyway to find out what rules the emulator is applying?

2

Answers


  1. Chosen as BEST ANSWER

    The issue was that I wasn’t calling connectFirestoreEmulator to connect firestore with the emulator. It was calling the cloud Firestore when it was signed into the emulator’s authentication service, leading to the missing or insufficient permissions error.


  2. It uses the same file that it was configured to deploy, which is firestore.rules in the same directory by default. It’s the same file as the one you specify in firebase.json. You shouldn’t have to do anything special to get normal expected behavior. The emulator does not use any rules that you modified in the Firebase console – your local file must contain the rules to use.

    When you run the emulator, it will generate a file firebase-debug.log which will give you plenty of information about what it’s doing, including which rules file it loaded. Look for a line that contains "Starting Firestore Emulator with command", and the command will show a --rules argument with the path of the file it uses.

    If you have clear proof that it’s not doing that in the most simple case, you should file an issue with your steps to reproduce on GitHub. Your steps should start with the creation of a new project with the CLI, and everything you’re doing up to the point of the unexpected result.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search