【问题标题】:firestore security rules at request.auth.uid == idrequest.auth.uid == id 处的 firestore 安全规则
【发布时间】:2020-06-09 11:09:26
【问题描述】:

我尝试设置基本安全规则,并将从 request.auth 返回的 uid 作为文档 ID 存储在我的文档中,但是在设置规则时

match /users/{id} allow read,write: if request.auth.uid == id

它不允许。这是为什么? 提前致谢。

【问题讨论】:

    标签: google-cloud-firestore firebase-security


    【解决方案1】:
    1. 您必须指定正确的文档名称,而不是像 /users/{id} 这样的别名。
    2. 您必须根据您的规则指定请求者的 uid,与文档名称相同

    总结一下,试试:

    位置=/users/dummyid

    uid=dummyid

    【讨论】:

    • 根据文档,花括号应该代表文档 ID 吗?我尝试了以下方法并且它有效,但奇怪的是花括号没有? match /users/{userId} { allow read, update, delete: if request.auth.uid == get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userId allow create: if request.auth.uid != null; }
    猜你喜欢
    • 2018-05-28
    • 2019-03-05
    • 1970-01-01
    • 2019-11-18
    • 2018-10-19
    • 2019-07-05
    • 2020-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多