2016-01-29 44 views

回答

2

好問題。

當我們說規則級聯時,將其讀取爲權限事例。一旦您有權讀取節點,您就不能在較低級別上獲得該許可。

所以,你可以開始".read": false在頂層,然後讓(從Firebase documentation on security rules片斷)讀取下:

{ 
    "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, 

但是反過來不行。你不能說一旦你說每個人都可以看到所有的房間名稱,就不允許任何人看到特定的房間名稱:

// 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 
     } 
相關問題