【发布时间】:2015-09-09 01:42:21
【问题描述】:
我很难为构建基于团队的协作平台编写安全规则。
- 当用户注册时,他们应该能够创建一个团队并邀请用户加入该团队。
- 项目应归团队所有。
- 只有该团队中的用户才能查看该项目。
- 用户只能看到他们所属的团队。
我如何编写.read安全规则,以便用户只能看到他们所在团队的信息?
我应该只列出两个团队,因为我属于他们 github:8272012.
当前的安全规则:
{
"rules": {
".read": true,
"users": {
"$user": {
//can add a message if authenticated
".write": "auth.uid === $user"
}
},
"teams": {
"$team": {
"users": {
// can write to the users list only if ADMINISTRATOR
"$user": {
".write":"newData.parent().child(auth.uid).val() === 99"
}
}
}
},
"projects": {
"$team": {
"$project": {
//can add a message if they are a MEMBER
".write": "(!data.exists() && newData.exists() && root.child('teams/' + $team + '/users/' + auth.uid).val() >= 10)"
}
}
}
}
}
我应该只列出两个团队,因为我属于他们github:8272012。
【问题讨论】:
-
我建议您查看有关 Firebase 中基于角色的安全性的要点:gist.github.com/sararob/331760829a9dcb4be3e7 以及指南的基于用户的安全部分:firebase.com/docs/security/guide/user-security.html
-
@Sara 我认为这正是我所需要的。稍后会继续工作。
标签: firebase angularfire