Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase firstore security rules for cloud functions

im currently setting up a dialogflow bot (for faq and contact) and the fulfillment / data storage is being done in firebase firestore using google cloud functions (nodejs).

Obviously I would like to have security rules, limiting the access to the database to only dialogflow. Could anyone point me in the right direction how I would go about doing this?

The examples I found, were all check regarding something stored in the database, which wouldn't work in my case..?

like image 665
f5172c0d83892c41b60de3f1fadd89 Avatar asked Dec 11 '18 15:12

f5172c0d83892c41b60de3f1fadd89


People also ask

Do firestore rules apply to cloud functions?

Since Cloud Firestore backend SDKs running in Cloud Functions have privileged access to Cloud Firestore, they will bypass all security rules.

What file should be used for firestore rules firestore rules?

firestore. rules // is a file used to define the security rules for your Firestore database. firestore.

How do you change cloud rules on firestore security?

To set up and deploy your first set of rules, open the Rules tab in the Cloud Firestore section of the Firebase console. Write your rules in the online editor, then click Publish.

Are Firebase functions secure?

Firebase gives direct access to Firestore from an app using the Firebase SDK, and that access is protected by security rules that you deploy to your project.


1 Answers

Security rules are only relevant when you have a mobile client (Android, iOS, web) directly accessing some data in Firestore, Cloud Storage, or Realtime Database. It also applies to unauthenticated access from the REST API. Any other access from a backend, including code you might write for a dialogflow fulfillment hook, isn't subject to security rules. That is to say, accessing these resources from a backend through the admin SDK ignores security rules altogether.

If you only intend to access these products from a backend, just make your your security rules disallow public access from mobile clients.

like image 70
Doug Stevenson Avatar answered Oct 02 '22 12:10

Doug Stevenson