根节点是否在 Firebase 中将大小写为子节点及其子节点



在文档中它告诉规则级联,孩子不能撤销权限,但后来在聊天示例中根读写规则默认为 false,那么为什么它不级联?文档链接

好问题。

当我们说规则级联时,请将其视为权限案例。一旦您拥有读取节点的权限,就不能在较低级别取消该权限。

因此,您可以从顶层的".read": false开始,然后允许较低的读取(Firebase 安全规则文档中的代码片段):

{
  "rules": {
    ".read": false,
    "room_names": {
      // the room names can be enumerated and read
      // they cannot be modified since no write rule
      // explicitly allows this
      ".read": true,

但相反是行不通的。你不能说没有人可以看到特定的房间名称,一旦你说每个人都可以看到所有的房间名称:

// THIS SNIPPET WILL NOT WORK
{
  "rules": {
    ".read": false,
    "room_names": {
      // the room names can be enumerated and read
      // they cannot be modified since no write rule
      // explicitly allows this
      ".read": true,
      "my_secret_room": {
          // THIS WILL NOT WORK
          // since we've said that every can read all room names
          // we cannot take that permission away anymore
          ".read": false
      }

最新更新