他们可以创建不同的用户并修改该用户's data which is fine. However they won't能够获取该匿名用户的数据 . 您可以通过设置以下规则,确保只有特定用户(由唯一用户ID标识)才能访问他/她自己的数据 . 每个匿名用户都有一个唯一的uid: { "rules": { "users": { "$user_id": { // grants write access to the owner of this user account // whose uid must exactly match the key ($user_id) ".write": "$user_id === auth.uid", // You can do the same for reads. ".read": "$user_id === auth.uid" } } } } 有关详细信息,请查看文档:https://firebase.google.com/docs/database/security/user-security
1 回答
他们可以创建不同的用户并修改该用户's data which is fine. However they won't能够获取该匿名用户的数据 . 您可以通过设置以下规则,确保只有特定用户(由唯一用户ID标识)才能访问他/她自己的数据 . 每个匿名用户都有一个唯一的uid:
{ "rules": { "users": { "$user_id": { // grants write access to the owner of this user account // whose uid must exactly match the key ($user_id) ".write": "$user_id === auth.uid", // You can do the same for reads. ".read": "$user_id === auth.uid" } } } }
有关详细信息,请查看文档:https://firebase.google.com/docs/database/security/user-security这可以保护匿名登录真实应用程序的用户不会通过某些网络钓鱼应用程序从外部访问其数据 .
但是,您无法使用API密钥和注册匿名用户来防范某人 . 如果您需要更安全的登录机制,可以查看具有源验证机制的OAuth提供商或电话登录 .