4

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

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

这个安全规则是什么样的?

谢谢。

4

1 回答 1

6

您可以禁止读取父级,但如果 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-29T18:49:40.720 回答