Member-only story

Advanced examples of using Cloud Firestore Security Rules

Kacper Hreniak
6 min readMar 24, 2019

--

Articles:

  1. Basic examples of using Cloud Firestore Security Rules
  2. Advanced examples of using Cloud Firestore Security Rules

In the previous article, I’ve presented some basic examples of using Cloud Firestore Security Rules. Now I will show you and explain more advanced examples, such as creating a condition using token information, comparing incoming data with stored data, and I want to explain to you information about using time in conditions.

Photo by Jan Antonin Kolar on Unsplash

Advanced conditions with the request

In the previous article I created an example where I’ve shown you how to use request object to get information about uid of the requested user. Now I’m going to show you more available properties in incoming request.

You can use the syntax: request.auth.token to get a JWT token and extract some useful information from it. The Firebase JWT token consists of the following values:

  • name —user’s display name
  • sub — user’s Firebase uid
  • email — email address
  • email_verified — information about the verified e-mail address
  • firebase.identities — map of user identities

--

--

Kacper Hreniak
Kacper Hreniak

Written by Kacper Hreniak

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

Responses (6)