gpt4 book ai didi

FireBase 规则不适用于 auth.uid

转载 作者:行者123 更新时间:2023-12-04 03:10:33 25 4
gpt4 key购买 nike

我正在尝试设置一个 Firebase 规则,如果 $uid 等于 auth.uid,将授予对 R/W 的访问权限。

这是我的数据库结构的示例:

enter image description here

我尝试的第一个规则配置:

{
"rules": {
"$uid" : {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}

我也试过这种方式(包括root的路径):

{
"rules": {
"AppName-46ed8":{
"$uid" : {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}

我遵循 Firebase 说明并且此规则通过了模拟器。

当这些规则到位时,我不会从 Firebase 获取带有快照的实例。

如果我按如下方式使用默认的“不安全”规则,一切都会正常运行(但会受到黑客威胁):

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

请指教。

最佳答案

遵循它应该有效:

These rules require authentication

Allow only authenticated content owners access to their data

{
"rules": {
".read": "auth != false",
".write": "auth != false",
"Users": {
"$id":{
".read": "auth.uid == $id",
".write": "auth.uid == $id",
}
},
}
}

关于FireBase 规则不适用于 auth.uid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45629967/

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