2013-06-29 37 views
4

我有一個firebase位置與我的應用程序的所有存儲的消息作爲子對象。firebase限制讀取到個別孩子,但不是父母

我希望客戶端能夠獲取每條消息,如果他們知道消息的id但不下載整個消息表。

這個樣子的安全規則是什麼樣的?

謝謝。

回答

6

,您可以禁止父讀,但允許讀取,如果ID是已知的:

"rules": { 
    "messages": { 
    // Disallow enumerating list of messages 
    ".read": false, 
    ".write": false, 
    "$messageID": { 
     // If you know the messageID you can read the message. 
     ".read": true, 
     // Cannot overwrite existing messages (optional). 
     ".write": "!data.exists()" 
    } 
    } 
} 

對於使用難以猜測的網址安全的示例應用程序見https://github.com/firebase/firepano