I have some data in firebase that I want to query. My firebase has default security settings which is readonly. However when I try to query the data as below
this.firestore.collection('myCollection').valueChanges().pipe().subscribe(x => {
console.log;
});
this.firestore.collection('myCollection').get().subscribe(x => {
console.log;
});
I do get an error Missing or insufficient permissions.
As per my understating that should not be the case as I am just reading the data. Also I probably have to mention that I am using @angular/fire
Just for an experiment I did try to enable the write access to database and it works this way but I want to keep the readonly mode.
that is my rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
Any ideas?
With
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
you are not allowing readonly access, since it is equivalent to
....
allow read: if false; // <- You deny any read here
allow write: if false;
....
You need to adapt your rules as follows:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read: if true;
allow write: if false;
}
}
}
More info in the doc, including the video at the top of the doc.