【问题标题】:Firebase Security & RulesFirebase 安全与规则
【发布时间】:2016-06-29 12:18:41
【问题描述】:

我必须在 Firebase“安全与规则”中添加一组规则,但在新版本中找不到。规则如下。我指的是 this manual 将这些规则添加到 Firebase 中的“安全与规则”中。我需要一些指南来添加这些规则:

{
  "rules": {

    "users": {
      "$uid": {
        // grants write access to the owner of this user account whose uid must exactly match the key ($uid)
        ".write": "auth !== null && auth.uid === $uid",
        // grants read access to any user who is logged in --&& auth.provider === 'password'
        ".read": "auth !== null"
      }
    },

    "usernames": {
      "$userName": {
        // grants write access to the owner of this user account whose uid must exactly match the key ($uid)
        ".write": "root.child('usernames').child($userName).child('uid').val() == auth.uid || root.child('usernames').child($userName).child('uid').val() == null",
        // grants read access to any user who is logged in --&& auth.provider === 'password'
        ".read": "auth !== null"
      }
    },

    "following": {
      "$uid": {
        // grants write access to the owner of this user account whose uid must exactly match the key ($uid)
        ".write": "auth !== null && auth.uid === $uid",
        // grants read access to any user who is logged in --&& auth.provider === 'password'
        ".read": "auth !== null"
      }
    },

    "followedBy": {
      "$fid": {
        "$uid": {
          // grants write access to the owner of this user account whose uid must exactly match the key ($uid)
          ".write": "auth !== null && auth.uid === $uid",
          // grants read access to any user who is logged in --&& auth.provider === 'password'
          ".read": "auth !== null"
        }
      }
    }

  }
}

我目前看到的是:

【问题讨论】:

    标签: firebase firebase-authentication firebase-security firebase-console


    【解决方案1】:

    单击左侧的数据库,您将在顶部有选项,单击规则选项卡,您将看到并能够在那里编辑您的规则。

    【讨论】:

      猜你喜欢
      • 2016-06-27
      • 1970-01-01
      • 2019-04-16
      • 2020-11-27
      • 2016-08-19
      • 2020-09-06
      • 2016-07-16
      • 1970-01-01
      相关资源
      最近更新 更多