【问题标题】:Authenticated server with a secret is not admin具有秘密的经过身份验证的服务器不是管理员
【发布时间】:2016-04-11 05:26:22
【问题描述】:

我不明白为什么通过 authWithCustomToken(secret,funct()) 进行身份验证的节点服务器似乎没有获得管理员权限:

   myFirebaseRef = new Firebase(url);
   myFirebaseRef.authWithCustomToken(secret,function(error, authData) {
      if (error) {
        console.log(currTime() + " [CONFIG] ... Firebase authentication failed!", error);
      } else {
        console.log(currTime() + " [CONFIG] ... Firebase authentication succeeded, authData : " + JSON.stringify(authData));
      }
   }

身份验证似乎成功:

07:13 [CONFIG] ... Firebase 身份验证成功,authData : {"auth":null,"expires":null,"token":"","uid":null,"provider":"custom "}

当我的服务器尝试更新孩子时:

FIREBASE 警告:在 /bd/google:112747494449447764778/9782871294917 更新失败:permission_denied

我的客户端代码已正确验证并获得预期的权限。

我的规则:

    {
    "rules": {
      ".read": true,
      "bd": {
        ".read": true,
        "$usernode": {
          ".read": true,
          ".write": "auth != null && auth.uid == $usernode"
         }
       }
     }
   }

有什么提示吗?

【问题讨论】:

  • 你确定认证成功了吗?因为 auth 为空
  • 在这种情况下我不应该得到错误吗?另外,有什么方法可以在我的 firebase 端调试安全性?
  • 此线程表明,当使用秘密而不是 JWT 时,身份验证数据应为空。 stackoverflow.com/questions/29594308/…

标签: firebase firebase-security


【解决方案1】:

我在 Firebase 对象中引用的 url 不是根,而是“/bd”。 更正后,服务器确实具有管理员权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-01
    • 2012-04-02
    • 2020-09-01
    • 2018-03-28
    • 1970-01-01
    • 2018-09-22
    相关资源
    最近更新 更多