Dan*_*e B 3 firebase-security firebase-authentication google-cloud-firestore
我想了解基于身份验证的安全规则是多么安全,如下所示:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一些集合,其中每个文档都与特定用户相关.
我只在移动设备上使用Cloud Firestore,包括Android和iOS,而不是网络.
有没有办法让用户在我的移动应用程序之外进行身份验证,从而读取或写入其他用户的文档?
如果您想确保用户无法阅读彼此的信息,您应该实施更强的规则auth != null.
例如,这些规则使得只有在/users/userId您通过身份验证时才能读取和写入数据userId.
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
// Anybody can write to their ouser doc
allow read, write: if request.auth.uid == userId;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这将使某人无法"在我的移动应用程序之外进行身份验证,因此会像您提到的那样读取或写入其他用户的文档".
| 归档时间: |
|
| 查看次数: |
1301 次 |
| 最近记录: |