【问题标题】:Firebase: Allow Read of property names, but not contentFirebase:允许读取属性名称,但不允许读取内容
【发布时间】:2017-03-21 02:33:35
【问题描述】:

允许任何人读取属性名称但阻止没有身份验证的人读取值的内容的正确数据库规则是什么。这是一个订单系统,我在设置属性值之前检查是否存在相同的 ID。或者还有其他方法可以做到这一点吗?谢谢。

这是我目前所知道的。

{
  "rules": {
    "orders": {
      ".read": true,
      ".write": true,

    }
  }
}

【问题讨论】:

    标签: firebase firebase-realtime-database firebase-security


    【解决方案1】:

    在 Firebase 数据库安全模型中,您可以访问整个节点,也可以无权访问它。您不能授予用户访问集合中每个节点的子集的权限。见rules cascade in the documentation

    通常,您会将集合分成两部分:一是公共部分,另一部分是私有部分。

    {
      "rules": {
        "ordernames": {
          ".read": true,
        },
        "orders": {
          ".read": "auth !== null",
        }
      }
    }
    

    另见:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-25
      • 1970-01-01
      • 2020-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多