【问题标题】:How to Secure Firebase in client side Javascript如何在客户端 Javascript 中保护 Firebase
【发布时间】:2014-03-31 07:32:31
【问题描述】:

我正在使用 Firebase 和 Ruby on Rails (4.0.3)。客户端 JS 正在侦听特定 URL 上的事件。显然,URL 对客户端是可见的,并且添加任何基于令牌的身份验证都是无用的,因为它也是可见的。有什么办法吗?

【问题讨论】:

    标签: javascript ruby-on-rails firebase firebase-security


    【解决方案1】:

    Firebase 支持一个安全规则系统,该系统定义谁可以在您的 Firebase 中读取或写入信息。您可以通过编写这样的 json 来定义它们:

    {
      "rules": {
        "foo": {
          // /foo/ is readable by the world
          ".read": true,
    
          // /foo/ is writable by the world
          ".write": true,
    
          // data written to /foo/ must be a string less than 100 characters
          ".validate": "newData.isString() && newData.val().length < 100"
        }
      }
    }
    

    这个话题还有很多不适合放在 Stack Overflow 上的答案,所以请查看Firebase's official documentation on security

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-14
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 2015-10-29
      • 2020-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多