【发布时间】:2021-04-03 20:48:34
【问题描述】:
我有一个 firebase 数据库,只有 3 个主要节点。这是一个聊天应用,下面是结构
chat_messages
- chatID
-messageID
-message (string)
-read (bool)
-senderName (string)
-senderProfilePic (string)
-sent_by (string)(uid)
-timestamp (string)
chat_room
-chatID
-chat_mode (string)
-last_message (string)
-timestamp (string)
-members
-uid (string)
-email (string)
-name (string)
-photo (string)
-uid (string)
-userID (int)
-userRole (string)
user_chatrooms
-uid
-chatID( string) : timestamp (string)
我设置了基本安全性,允许 read 和 write 到 true,我收到了一封来自 firebase 的电子邮件,说我的数据库有 insecure rules
然后我重新配置数据库规则如下
{
"rules": {
"chat_messages":
{
".read": "auth != null",
".write": "auth != null",
},
"chat_room":
{
".read": "auth != null",
".write": "auth != null",
},
"user_chatrooms":
{
".read": "auth != null",
".write": "auth != null",
}
}
}
这通过阻止对上述节点之外的任何其他内容的访问来提供额外的保护。
现在如何防止这些节点被删除?
【问题讨论】:
标签: database firebase firebase-realtime-database database-design firebase-authentication