且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

适用于特定用户的Firebase数据库规则

更新时间:2023-12-01 22:28:34

您应检查

You should check the auth variable.

要定义仅允许通过此电子邮件地址firebaseowner@gmail.com对所有位置进行写访问的安全规则:

To define the security rules that allow write access to all the locations by this email address firebaseowner@gmail.com only:

{
  "rules": {
    ".read": true,
    ".write": "auth != null && auth.token.email == 'firebaseowner@gmail.com'"
  }
}

要定义仅允许通过此电子邮件地址firebaseowner@gmail.com仅访问位置/users的安全规则,请执行以下操作:

To define the security rules that allow write access to only the location /users by this email address firebaseowner@gmail.com only:

{
  "rules": {
    ".read": true,
    "users": {
      ".write": "auth != null && auth.token.email == 'firebaseowner@gmail.com'"
    }
  }
}