Firestore数据库规则-“创建"规则不适用于云功能 [英] Firestore Database Rules - "Create" Rule Not Working for Cloud Functions

查看:64
本文介绍了Firestore数据库规则-“创建"规则不适用于云功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用HTTP云功能创建的文档的数据库规则

所附图片显示了两件事:

The attached image shows two things:

  1. Firestore数据库集合的屏幕快照,其中包含一个通过http云功能创建的文档

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

Firestore 2.0规则的屏幕截图.

Screenshot of Firestore 2.0 rules.

规则 编写规则allow create: if request.resource.data.replyTo == "hello";是为了防止创建任何文档,除非'replyTo'=="hello".

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

问题 为什么在'replyTo'=='john@smith.com'时允许创建文档?

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

推荐答案

Cloud Firestore安全规则仅适用于Android,iOS和Web客户端库.不适用于服务器端(使用firebase admin SDK的云功能).

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

请参见 https://firebase.google.com/docs/firestore/security/overview

对于移动和Web客户端库,请使用Firebase身份验证和Cloud Firestore安全规则来处理无服务器身份验证,授权和数据验证.了解如何使用Cloud Firestore安全规则为Android,iOS和Web客户端库保护数据.

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.

这篇关于Firestore数据库规则-“创建"规则不适用于云功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆