实时数据库的Firebase安全规则

发布于 2025-01-29 15:51:59 字数 161 浏览 4 评论 0原文

我正在尝试为Firebase实时数据库设置规则。规则设置为

"rules": {
".read": true,
".write": true

} 这使它公开,但我想将其设置为私人,我想访问它。不仅是通过控制台,而且还通过Angular应用程序。

I am trying to set rules for the firebase Realtime Database. Rules are set to

"rules": {
".read": true,
".write": true

}
This makes it public but I want to set it to private and I want to access it. Not only through the console but the Angular app.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空袭的梦i 2025-02-05 15:52:00

您需要登录以获取auth对象,然后可以使用user-id限制访问:

{
  "rules": {
    "users": {
      "$user_id": {
        // grants write access to the owner of this user account
        // whose uid must exactly match the key ($user_id)
        ".write": "$user_id === auth.uid"
      }
    }
  }
}

https://firebase.google.com/docs/database/security/rules-conditions#authentication

You need to login to get an auth object and then can use the user-id to restrict access:

{
  "rules": {
    "users": {
      "$user_id": {
        // grants write access to the owner of this user account
        // whose uid must exactly match the key ($user_id)
        ".write": "$user_id === auth.uid"
      }
    }
  }
}

https://firebase.google.com/docs/database/security/rules-conditions#authentication

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文