firebase limit 读给单个 child ,但不读给 parent

标签 firebase firebase-security

我有一个 firebase 位置,其中我的应用程序存储的所有消息都作为子对象。

我希望客户端能够在知道消息 ID 的情况下获取每条消息,但不下载整个消息表。

这方面的安全规则是什么样的?

谢谢。

最佳答案

您可以禁止读取父级,但如果 ID 已知则允许读取:

"rules": {
  "messages": {
    // Disallow enumerating list of messages
    ".read": false,
    ".write": false,
    "$messageID": {
      // If you know the messageID you can read the message.
      ".read": true,
      // Cannot overwrite existing messages (optional).
      ".write": "!data.exists()"
    }
  }
}

参见https://github.com/firebase/firepano一个使用不可猜测的 URL 来确保安全的示例应用程序。

关于firebase limit 读给单个 child ,但不读给 parent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17383168/

相关文章:

java - 如何跟踪 Firestore 读/写操作?

android - 在 Firebase 中生成 6 位唯一编号

Firebase:使用admin sdk存储图像

ios - Firebase 权限 : Sign up with username and password

Firebase 安全 : read-only parent node, 但可写子节点

swift - Firebase规则获取目标用户uid

ios - strip 创建用户 firebase 云函数

ios - 无法将数据从 firebase 加载到 Tableview

javascript - $uid 节点如何在 firebase-realtime-database 规则上工作?

firebase - Firestore安全规则中的递归通配符未按预期工作