让我们来谈谈
基本的
可以实现的安全规则(通过用户身份验证):
allow read, update, delete: if request.auth.uid != null;
allow create: if request.auth.uid != null;
任何用户都可以删除其他人创建的文档。因此,为了限制/控制它,我们实现了所提供的代码片段。
service cloud.firestore {
match /databases/{database}/documents {
// Make sure the uid of the requesting user matches name of the user
// document. The wildcard expression {userId} makes the userId variable
// available in rules.
match /users/{userId} {
allow read, update, delete: if request.auth.uid == userId;
allow create: if request.auth.uid != null;
}
}
}
代码片段只是一个示例用例,它使用不同的条件作为参考,因为这是一个教程/指南,所以Firebase团队尝试为代码片段提供尽可能多的条件。
你当然可以
allow create: if request.auth.uid == userId;
严格限制该特定用户。
我希望它能给你一些想法!