Firestore Database Rules - “Create” Rule Not Working for Cloud Functions

◇◆丶佛笑我妖孽 提交于 2020-05-07 09:24:26

问题


Database Rules for Documents Created with HTTP Cloud Function

The attached image shows two things:

  1. Screenshot of Firestore database collection with one document that was created via http cloud function

  2. Screenshot of Firestore 2.0 rules.

Rule The rule allow create: if request.resource.data.replyTo == "hello"; was written to prevent any document from being created unless 'replyTo' == "hello".

Question Why was the document allowed to be created when 'replyTo' == 'john@smith.com' ?


回答1:


Cloud Firestore Security Rules is only for the Android, iOS, and Web client libraries. Not for server side(cloud functions using firebase admin SDK).

See https://firebase.google.com/docs/firestore/security/overview

For mobile and web client libraries, use Firebase Authentication and Cloud Firestore Security Rules to handle serverless authentication, authorization, and data validation. Learn how to secure your data for the Android, iOS, and Web client libraries with Cloud Firestore Security Rules.



来源:https://stackoverflow.com/questions/60191098/firestore-database-rules-create-rule-not-working-for-cloud-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!