Let me ask you how to setup security rules in Cloud Firebase Console. I've studied official Firebase documentation https://firebase.google.com/docs/firestore/security/rules-conditions?authuser=0 and this article https://angularfirebase.com/lessons/firestore-security-rules-guide/, but I'm not able to figure out behavior of security rules in my app.
What's the problem?
Firstly I'd like to start with very basic type of rules. I want to allow the user to access to products collection anyway and block access to orders collection if the user in unauthenticated (not logged in).
My rules looks like this:
service cloud.firestore {
match /databases/{database}/documents {
match /categories/{category} {
allow read, write;
}
match /products/{product} {
allow read, write, list, get, update;
}
match /orders/{order} {
allow read, write: if request.auth.uid != null;
}
}
}
And how it works at this moment:
I'm able to read, write products collention only in my app's admin panel (so I can mange products) but on customer side, products are blocked. In Firebase Console this rule passed the test (see screanshot) but in dev console I can see a message: "Missing or insufficient permissions". 10 minutes went by and the result is the same. And it's unclear for me, because I've setup a rule to allow access to products anytime (line no. 9).
second problem is, if I test orders collention I have an error "Error: simulator.rules line [13], column [29]. Null value error (see screanshot).
So, would you mind to help fix the foregoing issues?
Additional usefull inforation:
- Angular6 | Firebase 5.2.0 | AngularCLI 6.0.8 | Authentication method via Google
Thank You!