gpt4 book ai didi

swift - Firebase 说我的规则不安全,为什么?

转载 作者:可可西里 更新时间:2023-11-01 00:20:02 25 4
gpt4 key购买 nike

我收到了一封来自 Firebase 的电子邮件,通知我我的安全规则是不安全的,理由是:任何用户都可以读取/写入您的数据库。

这怎么可能,我在下面指定了.read.write 规则。 我错过了什么?如有任何帮助,我们将不胜感激。

{
"rules": {
".read": "auth != null",
".write": "auth != null",
"venues-location": {
".indexOn": "g"
},
"users-compliments": {
"$uid":{
"$uid":{
".indexOn": ".value"
}
}
},
"users-invites": {
"$uid":{
"$uid":{
".indexOn": ".value"
}
}
},
"users-location": {
".indexOn": "g"
}
}
}

最佳答案

".read": "auth != null",

".write": "auth != null",

以上这些规则是默认规则。根据 firebase documentation它们允许对您的应用程序的经过身份验证的用户进行完全读写访问。如果您希望数据对应用的所有用户开放但又不想向全世界开放,它们就很有用

在启动您的应用程序之前正确配置这些规则非常重要,以确保您的用户只能访问他们应该访问的数据。

{
"rules": {
"foo": {
".read": true,
".write": false
}
}
}

下面是一个规则示例,该规则为经过身份验证的用户授予对/users//的写入权限,其中是通过 Firebase 身份验证获得的用户 ID。

{
"rules": {
"users": {
"$uid": {
".write": "$uid === auth.uid"
}
}
}
}

关于swift - Firebase 说我的规则不安全,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51275219/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com