在文档中它告诉规则级联和子级无法撤销权限但后来在聊天示例中根读写规则默认为false,那么为什么它不级联? Doc link
答案 0 :(得分:2)
好问题。
当我们说规则级联时,请将其视为权限案例。一旦您有权读取节点,就无法在较低级别获取该权限。
所以你可以从顶层的{
"rules": {
".read": false,
"room_names": {
// the room names can be enumerated and read
// they cannot be modified since no write rule
// explicitly allows this
".read": true,
开始,然后允许读取更低(Firebase documentation on security rules的片段):
// THIS SNIPPET WILL NOT WORK
{
"rules": {
".read": false,
"room_names": {
// the room names can be enumerated and read
// they cannot be modified since no write rule
// explicitly allows this
".read": true,
"my_secret_room": {
// THIS WILL NOT WORK
// since we've said that every can read all room names
// we cannot take that permission away anymore
".read": false
}
但相反却不起作用。一旦你说每个人都可以看到所有房间名称,你就不能说没有人被允许看到特定的房间名称:
List list = new ArrayList();
for(int i = 0; i < n; i++) list.add(buyCoffee(cc));