firebase - 经过身份验证的用户无权访问 Firebase 中存储的数据

标签 firebase firebase-security firebasesimplelogin

我有一个经过身份验证的用户,该用户通过使用 FirebaseSimpleLogin 进行身份验证。该用户拥有 token :

'user':{
    email: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfa2b6aaa2aea6a38fa6a1bbaabda1aabbbce1aca0a2" rel="noreferrer noopener nofollow">[email protected]</a>",
    firebaseAuthToken: SOME TOKEN,
    "id: "4",
    isTemporaryPassword: true,
    md5_hash: "aHash123",
    provider: "password",
    uid: "simplelogin:4"
    }

我已在 Firebase 的“规则和安全”选项卡下授予经过身份验证的用户读取权限,使用方法:

{
  "rules": {
    "SOME DATA": {
      ".read": "auth.email == '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6c011509010d05002c050218091e0209181f420f0301" rel="noreferrer noopener nofollow">[email protected]</a>'", 
      ".write": true
    }
  }
}

但是,当访问数据时,我收到错误:

Error: permission_denied: Client doesn't have permission to access the desired data.

我是否遗漏了一些关于为什么我没有读取权限的基本信息?

最佳答案

在 firebase 的安全规则部分,我犯了一个错误。

{
  "rules": {
    "SOMEDATA": { //NOTE: removal of space character
      ".read": "auth.email == '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="83eefae6eee2eaefc3eaedf7e6f1ede6f7f0ade0ecee" rel="noreferrer noopener nofollow">[email protected]</a>'", 
      ".write": true
    }
  }
}

经验教训:规则非常具体,并始终遵循一些约定。

关于firebase - 经过身份验证的用户无权访问 Firebase 中存储的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28288744/

相关文章:

android - 如何在 React-native 中使用视频文件路径将视频存储在 firebase 存储中

node.js - Dialogflow v2 使用 Firebase Cloud Function 返回 Firestore 数据库数据

Firebase 函数版本 "Deploy to multiple environments"

angularjs - 如何防止 Firebase 中出现重复的用户属性?

firebase - Firestore 安全规则。允许阅读完整集合(文档和子集合)

ios - 适用于 ios 的 Firebase facebook 登录(swift) - 使用未解析的标识符 'FBSDKLoginManager'

Firebase 弹出窗口在调用登录后关闭

swift - Firebase swift tabBarController 最佳实践

angularjs - 如何让 Controller 等待服务返回值以及如何访问 Controller 中的返回值?

firebase - 子集合的 Cloud Firestore 规则