Firebase模拟器不允许“读取”,但它正在生产中

时间:2016-12-23 06:58:35

标签: firebase firebase-realtime-database firebase-security

在使用模拟器测试Firebase安全规则的路径/待定帖子中“读取”期间,我发现规则在生产中工作正常,但模拟器显示读取被拒绝。我花了几个小时来识别,模拟器存在真正的问题。下面是我的安全规则。

    {
      "rules": {
        "pending-posts":{
          ".read":"auth.token.role.matches(/moderator$/)",
          ".write": "auth.uid != null"
        },
      }
    }I am using custom authentication and below is my token
    {
      "uid": "SYS1904",
      "iss": "firebase-adminsdk-h08vu@gooonj-1293e.iam.gserviceaccount.com",
      "sub": "firebase-adminsdk-h08vu@gooonj-1293e.iam.gserviceaccount.com",
      "aud": "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
      "iat": 1482300927,
      "exp": 1482302127,
      "claims": {
        "empCode": "SYS1904",
        "empName": "Anil Kumar",
        "role": "moderator",
        "photo": "SYS1904-5b8af31fba.jpg"
      }
    }Below is my database JSON-
    { 
  "pending-posts" : {
    "-KZzww9RSz_zxJW-ZxHY" : {
      "author" : "Sharma",
      "body" : "frank",
      "commentCount" : 0,
      "likeCount" : 0,
      "starCount" : 0,
      "timeStamp" : 1482836658167,
      "title" : "hi",
      "uid" : "TYS65598981",
      "url" : ""
  }
}

0 个答案:

没有答案