Basic examples of using Cloud Firestore Security Rules

Kacper Hreniak
4 min readMar 21, 2019

Articles:

  1. Basic examples of using Cloud Firestore Security Rules
  2. 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.

Photo by Dayne Topkin on Unsplash

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;
}

--

--

Kacper Hreniak

Senior Mobile Software Engineer — Android platform, Clean code, Data Structure and Algorithm, Blockchain