firebase limit read to individual children but not to parent

 ̄綄美尐妖づ 提交于 2020-01-02 05:16:34

问题


I have a firebase location with all of my app's stored messages as child objects.

I want clients to be able to get each message if they know the id of the message but not download the entire messages table.

What would the security rule for this look like?

Thanks.


回答1:


You can disallow a read on the parent, but allow reads if the ID is known:

"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()"
    }
  }
}

See https://github.com/firebase/firepano for an example app that uses unguessable URLs for security.



来源:https://stackoverflow.com/questions/17383168/firebase-limit-read-to-individual-children-but-not-to-parent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!