firebase - Firebase 数据库规则中不同用户的多个规则
问题描述
更新:
这就是我的firebase db的结构看起来像它有两个主要节点结果和调查所示的“
这些是我目前的规则:
{
"rules": {
"surveys": {
".indexOn":["userId"],
".read": true,
".write": "auth.uid != null"
},
"results": {
".read": "auth.uid != null",
"$resultid": {
".write": true
}
}
}
}
基本上,当用户进行新调查时,它会被存储,它将模板保存在调查中,现在只有经过身份验证的用户才能写入它,所以它非常好,现在是阅读部分,现在任何人都可以阅读整个调查节点,我无法将 auth != null 添加到它,因为当有人分享他们的调查时,即使未经身份验证的用户也应该能够阅读该特定调查并进行操作,所以我应该怎么做才能不允许每个人都阅读整个调查节点但是只有他们应该阅读的那个,否则任何人都可以通过提取所有 ID 来执行任何人的调查。顺便说一句,$resultid 规则不起作用,现在仍然允许写访问:(
解决方案
The closest you can get it:
{
"rules": {
"surveys": {
".read": "auth != null",
"$surveyid": {
".read": true,
".write": true
}
}
}
}
These rules:
- Allow any authentication user to read all surveys.
- Allow anyone who knows a survey ID to read/write that survey. You'll note that this is slightly different than your second requirement, as there is no way to know who created each survey unless they are signed in.
Update
For the results you'd then add:
"results": {
".read": "auth != null",
"$resultid": {
".write": true
}
}
推荐阅读
- python - 为什么读入熊猫时日期列会失真?
- javascript - 我试图了解如何通过部分应用函数来删除参数
- javascript - TypeError:无法读取未定义 Discord.js 错误的属性“get”
- windows - Windows 10 上保存 docker 图像的默认位置
- html - 在 iOS Safari 上使用“位置:固定”时的元素截止
- kubernetes - 如何在运行该 pod 的节点上获取 pod 名称和命名空间?
- c# - 更改另一个属性后应用更改到一个属性
- google-cloud-platform - 如何判断默认 GCP Cloud Vision API 支持哪些实体?
- python - Google Colab 中的袖扣烛台图错误
- python - 在基类或扩展类之间进行选择 - Python