【发布时间】:2019-09-27 20:17:41
【问题描述】:
我在 Cloud Firestore 上有一个简单的聊天应用程序,它具有以下安全规则,仅允许用户在应用程序本身“加入”聊天室时在聊天室中发送消息:
match /hangouts/{hangout}/messages/{message} {
allow create, write, update, read: if exists(/databases/$(database)/documents/users/{userId}/hangout/{hangout});
}
如果用户在 Firestore 上的收藏中有一个 hangoutID,则应该允许他们将消息发送到该 hangoutID。但是,我仍然收到错误消息:
Write at hangouts/ChIJPRVm2R7H54kRKLP2ttsuUko/messages/17225E70-B708-4033-AE5A-D0CBBD1BC69F failed: Missing or insufficient permissions.
我还有 2 条与环聊相关的其他规则。有没有可能这些干扰?
match /hangouts/{hangout} {
allow read, update, write, create: if request.auth.uid != null;
}
match /hangouts/{hangout}/members/{userId} {
allow read: if request.auth.uid != null;
allow create, update, write, delete: if request.auth.uid == userId;
}
第一个是人们可以创建和查看聊天室环聊,第二个是允许人们加入他们。
我做错了什么?我对这个概念有点陌生。
谢谢!!
【问题讨论】:
标签: firebase google-cloud-firestore firebase-security