【发布时间】:2018-03-20 00:52:21
【问题描述】:
我在尝试写入 Firestore 时遇到错误。
我正在尝试将包含用户 uid 的字段用于我的安全规则。
service cloud.firestore {
match /databases/{database}/documents {
match /messages/{document=**} {
allow read: if resource.data.user_uid == request.auth.uid;
allow write: if resource.data.user_uid == request.auth.uid;
}
}
}
如果我的 Firestore 数据库中有数据,则读取规则可以正常工作 - 但是当我尝试写入时,我得到:Error: Missing or insufficient permissions.
这个写规则有什么问题吗?
附:如果我将规则更改为此,我可以写入我的数据库 - 但这对于我的目的来说不够安全:
match /messages/{document=**} {
allow read: if resource.data.user_uid == request.auth.uid;
allow write: if request.auth != null;
}
【问题讨论】:
标签: firebase firebase-security google-cloud-firestore