【问题标题】:How to make my Realtime database readable only by my users?如何使我的实时数据库只能由我的用户读取?
【发布时间】:2021-11-01 19:15:03
【问题描述】:

我使用 Firebase 实时数据库只是为了知道我是否仍然像建议者 here 那样连接到它。所以,里面什么都没有。

我认为我设置的规则已经足够了,但 Google 认为它不安全,我需要更改它。

所以,我从:

{
  "rules": {
    ".read": "auth != null",
    ".write": false
  }
}

到这里:

{
  "rules": {
    ".read": false,
    ".write": false
  }
}

这适用于我的 iOS 应用,但不适用于我的 Android 应用。由于建议的解决方案here,将“读取”设置为“错误”会使该解决方案不可行。

你有什么建议?

【问题讨论】:

    标签: firebase-realtime-database firebase-security


    【解决方案1】:

    对于那些有同样问题的人,这里是谷歌技术支持给我的建议

    你可以修改它有点像 FirebaseDatabase.getInstance().getReference(“connect/” + (new Date()).toString()).keepSynced()

    在您的实时数据库规则中,允许读取、写入 auth != null 到这个“连接”子节点。

    看起来像这样:

    {
    
      "rules": {
        "connect":{
          ".read": "auth != null",
          ".write": "auth != null"
        },
        ".write": false,
        ".read": false
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-06
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      • 2020-07-16
      • 2020-10-12
      • 2018-06-11
      • 1970-01-01
      相关资源
      最近更新 更多