Firestore中授权写入的安全规则

时间:2018-08-26 20:39:35

标签: firebase google-cloud-firestore firebase-security-rules

我在Firestore中具有以下安全规则:

match /myCollection/{myId} {
        allow read, update, delete: if resource.data.userId == request.auth.uid;
        allow create: if request.auth.uid != null && request.resource.data.userId == request.auth.uid;
}

这使我可以使用where()函数查询所有用户的文档。但是,对于访问像这样的单个文档不起作用:

FirebaseFirestore.getInstance()
    .collection(COLLECTION_NAME)
    .document(myKey);

(我收到PERMISSION_DENIED: Missing or insufficient permissions错误)

如何构造安全规则(或更改我阅读单个文档的方式),以确保用户只能访问自己的文档,还可以直接访问单个文档?

0 个答案:

没有答案
相关问题