In the last post we wrote Unit Tests for our Provider layer. We haven’t yet setup any security rules for our Firestore Database, and Firebase is kind enough to remind us of it every other day.

Today we’ll be setup our Firebase Project for CLI, and then deploy the Firestore rules. Let’s start.

Installing Firebase CLI

First up install Firebase CLI using the following command. If you don’t have npm installed or you don’t want to use npm checkout this quick start guide.

Once installation finishes, verify that it installed correctly.

Signing In To Firebase CLI

Run firebase login and authenticate with your firebase account.

firebase projects:list lists out all of your projects.

Create a new directory server inside your app directory. and run firebase init inside it. Choose Firestore and Functions when prompted for choices (We’ll need Cloud functions later).

Choose your current project on the next step and choose the default select options for all the next steps related to file naming and cloud functions setup.

Writing the Rules

Update your server/firestore.rules file with the following rules.

Deploying the Rules

Run firebase deploy — only firestore:rules to deploy the rules. Note that we’re only deploying the firestore rules at this point because we haven’t written any cloud funtions to deploy. That’ll be a different post.

Our rules are deployed now. You won’t get those annoying (but important) mails from Firebase now and our Database is now safe.

Hit me up in the comments below or Twitter or Linkedin or Instagram if you have any queries or suggestions or just for a casual tech talk maybe? See you guys in the next one!

References

Code Changes

#42 Added Firestore Rules

How Can You Contribute?

Open issues with suggestion of better approaches or ideas for the app.

Connect with me on Twitter or Linkedin or Instagram.

Star the Github repository.

Share the series on Twitter.

Follow me on Github.

Posts In This Series

Show Your Support

Press the clap button below if you liked reading this post. The more you clap the more it motivates me to write better!