【问题标题】:firebase limit read to individual children but not to parentfirebase 限制读取给单个孩子但不读取给父母
【发布时间】:2013-06-29 18:01:54
【问题描述】:

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

如果客户知道消息的 id 但不下载整个消息表,我希望他们能够获取每条消息。

对此的安全规则是什么样的?

谢谢。

【问题讨论】:

    标签: firebase firebase-security


    【解决方案1】:

    您可以禁止读取父级,但如果 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 以确保安全的示例应用。

    【讨论】:

      猜你喜欢
      • 2013-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-09
      • 1970-01-01
      • 1970-01-01
      • 2013-03-09
      相关资源
      最近更新 更多