[英]Firebase - How to set security rules so that only logged in users can read and write?
[英]Add security rules to let users read data that contains their uid only in Firebase
我在我的 firebase 控制台中編寫了這些安全規則,以便僅當登錄用戶的 uid 與項目和聯系人的 uid 值匹配時,項目和聯系人才能獲得讀寫權限。 我驗證了匹配的 uid,但不再顯示任何項目或聯系人。
{
"rules": {
"Projects" {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
}
},
"Contacts" {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
}
}
}
}
注意:每個項目都包含一個具有用戶 uid 的值。
我的數據庫結構:
my-database:
- Projects
-MYGDH884934939
uid: xxxxxxx
- Contacts
-MYGDH535578889
uid: xxxxxxx
登錄用戶具有相同的 uid = xxxxxxx
是這樣的嗎?
{
"rules": {
"Projects": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
},
"Contacts": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.