0
我在Firebase中有一个名为“pending_members”的字段,其中包含等待“所有者”授予待批准权限的成员列表,因此,“pending_members”需要以下内容规则:向Firebase添加安全措施以防止插入其他数据
- 当前用户只能从列表
- 的“所有者”添加本身(UID)
- 当前用户可仅去除本身(UID)可以从列表中删除任何构件
- 只有“所有者”才能阅读清单
我已经尝试了各种安全规则,但似乎错过了很多角落案例,例如,用户被给予写访问权限,因为数据包含他们的用户身份,但他们可以随后提交其他用户的uid。
任何人都可以针对这种情况提出适当的规则吗?非常感谢
"pending_members" : {
".write" : "auth !== null &&
// The user is authenticated AND
(newData.child(auth.uid).exists() ||
// The new data contains either the current user's id OR
(!newData.exists() &&
// There's no new data (a delete operation) AND
data === auth.uid))",
// The old data is the current user's id
"$member" : {
".validate" : "newData.isString()",
"$other": { ".write": false, ".read": false }
}
}
编辑: 结构示例:
users ->
personal_data ->
email (user email address)
first_name (user first name)
last_name (user last name)
networks_index ->
networks ->
members (list of uids of users linked to the network)
owner (uid of the owner/primary user)
pending_members (list of uids of users wishing to link to the network)
你可以添加一个firebase结构的例子吗? –
@AndréKool按要求添加。 –