【发布时间】:2018-05-17 12:53:08
【问题描述】:
来自 JS 应用的 Firebase 实时数据库安全性。
我允许所有密码验证用户具有读取权限。 然后,对于所有其他类型(根据我的方案,仅匿名),我想只允许读取特定的 /bundles/。
这些是规则-
{
"rules": {
".read": "auth != null && auth.provider == 'password'", // working!
"bundles": {
"$bundle": {
".read": "data.child('anonymous').val() == true", // not working
}
},
}
}
还有 /bundles -
"-L-2BbIkAg6J9WPMaJpJ": {
"anonymous": true,
"more_data": "data_1"
},
"-L-UHBr45eEUHGwsPWqq": {
"anonymous": false,
"more_data": "data_2"
}
我希望在以匿名身份登录时只看到第一个捆绑包,但我从 FB 收到错误 - “permission_denied at /bundles”。
【问题讨论】:
-
AFAIK Firebase 规则不过滤数据。您是否尝试进行类似
ref.child('bundles').once('value')的查询? -
它可以被视为过滤,但我的想法来自 - firebase.google.com/docs/database/security/…。具体来说 - "rules": { "messages": { "$message": { // 只能读取最近十分钟的消息 ".read": "data.child('timestamp').val() > (现在 - 600000)", } } }
标签: javascript firebase firebase-security