在我的Firebase安全规则中,我希望匿名用户能够读取除一个字段(secret_field)之外的任何内容:
{
"rules": {
".read": true,
".write": "auth != null",
"stuff" : {
"$stuffID" : {
"secret_field" : {
".read" : "auth != null"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,在Firebase中,如果secret_field评估为true 的方式上有任何读取规则,secret field则授予读取访问权限.
有没有办法扭转这种行为?(如果有任何读取规则secret_field评估为false,则禁止读取访问)
Mic*_*uer 10
您无法撤消行为,但您可以通过为公共字段引入"容器"并将.read设置为true来解决此问题.例如:
{
"rules": {
"stuff" : {
"$stuffID" : {
"public" : {
".read": true
},
"secret_field" : {
".read" : "auth != null"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后....../public /下的所有内容都可以被所有人访问,但是.../secret_field只能由经过身份验证的用户访问.
| 归档时间: |
|
| 查看次数: |
1603 次 |
| 最近记录: |