【问题标题】:How to fetch firebase firestore data at locked mode如何在锁定模式下获取 Firebase Firestore 数据
【发布时间】:2017-10-26 14:57:38
【问题描述】:
我使用 Firebase 开发了一个 Android 应用程序,在测试模式下使用云 Firestore。测试模式意味着“任何拥有我的数据库引用的人都可以读取或写入我的数据库”。然后我将安全规则更改为“allow read, write: if false”以防止这种情况发生。它被称为锁定模式。
但是在锁定模式下不会获取数据。谷歌没有为此提供适当的文档。我能做什么?
【问题讨论】:
标签:
android
firebase
google-cloud-firestore
【解决方案1】:
我会看看我们的Security Rules documentation,它将解释如何正确保护您的 Firestore 数据库。例如:
service cloud.firestore {
match /databases/{database}/documents {
// only a user can read and write their profile
match /users/{userId} {
allow read, write: if request.auth.uid == userId;
}
// any authenticated user can read and write messages
match /rooms/{roomId} {
match /messages/{messageId} {
allow read, write: if request.auth != null;
}
}
}
}
【讨论】:
-
你能解释一下@Mike McDonald这里的语法吗?我已阅读文档,并且正在尝试授予对与经过身份验证的用户匹配的节点的访问权限。但是,我不明白这些规则的语法。