【发布时间】:2019-09-29 15:54:43
【问题描述】:
我正在尝试为我的应用设置安全规则。
我有一个如下所示的集合:
Scores | | | | |___ AutoID______________history | |___value: 22 |__20190506 | |___userID: "abc" |___dateString:20190506 |___ AutoID |___value:22 |___value: 45 |___userID: "def"
我认为这样做可以:
match /scores/{docID=**} {
allow read: if userIsLoggedIn();
allow create, update: if request.resource.data.userID == request.auth.uid;
allow delete: if resource.data.userID == request.auth.uid;
}
用户可以达到分数,但不能达到Collection“历史”。
我认为问题来自resource.data.userID。
Collection“历史”无法访问resource.data.userID。我想从父文档访问resource.data.userID。
有可能吗?
【问题讨论】:
-
我不确定我是否正确理解了您的问题/问题,所以只指出一些事情。 1)匹配中的
/scores/{docID=**}表示这些规则授予的权限也适用于scores下的所有集合。 2) 读入安全规则本身不受安全规则影响。
标签: firebase google-cloud-firestore firebase-security