Basic examples of using Cloud Firestore Security Rules
Articles:
- Basic examples of using Cloud Firestore Security Rules
- Advanced examples of using Cloud Firestore Security Rules
Cloud Firestore Security Rules is a tool to define access control to your Firestore. You don’t have to worry about creating an authorization or authentication code for your database. In the dashboard of the Cloud Firestore Security Rules define matches to your collections or subcollections and create conditions for each of them to manage access to the Firestore.
1. Lock the Firestore
That’s a part of the code to block all operations in Firestore. You must remember that requests from Admin SDK are still possible.
match /{document=**} {
allow read, write: if false;
}
- Wildcard syntax
{document=**}
has been used to match all collections and subcollections in the Firestore. - A Simple condition
false
to block all operation
2. Unlock the Firestore
This’s an example of how to make your Firestore completely open to all requests and all users.
match /{document=**} {
allow read, write; // or allow read, write: if true;
}