【发布时间】:2019-06-20 22:56:51
【问题描述】:
用户、项目作为顶级集合,任务作为项目的子集合 以下是安全规则,我在允许对任务进行集合组查询时遇到了麻烦。即使我删除了对 createdBy 的检查,似乎也不起作用,当我为任务资源运行模拟器时,我的规则有效
match /projects/{projectID} {
allow read, delete, update: if request.auth.uid == resource.data.createdBy;
allow create: if request.auth != null;
}
match /users/{userID} {
allow read, delete, update: if request.auth.uid == userID;
allow create: if request.auth != null;
}
match /projects/{projectID}/tasks/{taskID} {
allow read, delete, update: if request.auth.uid == resource.data.createdBy;
allow create: if request.auth != null;
}
这是我的收藏组查询
_firestore
.collectionGroup('tasks')
.where('dueDate', isEqualTo: DateTimeHelper.today)
.where('createdBy', isEqualTo: user.id)
.snapshots()
.map((list) => list.documents.map((doc) {
String projectId = doc.reference.parent().parent().documentID;
String taskId = doc.documentID;
return Task.fromDocument(doc, taskId, projectId);
}).toList());
【问题讨论】:
标签: firebase google-cloud-firestore firebase-security