i've got this problem when calling firestore function from angular fire. When i'm succesfully authenticated, i'm fetching to firestore the current user document id for additional data associated with the user.

 // In App.Component
  ngOnInit(): void {
    this.afAuth.onAuthStateChanged((user) => {
      if (user) {
        // Some firestore call like
        // let p: QuerySnapshot<AppUser> = await this.firestore.collection<AppUser>('users').ref.where('uid', '==', 'myuserid').get(); 
        // --> FirebaseError: [code=permission-denied]: Missing or insufficient permissions.
       }
    });
  }

I don't understand because my rules for firestore are :

rules_version = '2';

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

so read and write are permitted to everyone.

I'm facing this error since i've enforced security as firebase console "AppCheck" suggested, now, as far as i remember, only specific applications are accepted and i've settled recaptcha, so is this occuring because recaptcha configuration is missing in my app ? Or maybe it's not related ? https://firebase.google.com/docs/app-check/web/recaptcha-provider

1

There are 1 best solutions below

0
sachaamm On

Following these steps made things works :

So the rules were not sufficient, a correct configuration of AppCheck was required in my case