-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.rules.json
189 lines (189 loc) · 5.57 KB
/
database.rules.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{
"rules": {
".read": false,
".write": false,
"v2": {
"announcement": {
".write": false,
".read": "auth != null"
},
"projects": {
".write": false,
".read": "
// all users can query by status
(auth != null && query.orderByChild == 'status' && query.equalTo == 'active')
||
(auth != null && query.orderByChild == 'status' && query.equalTo == 'build_area_tutorial' && query.limitToFirst == 1)
||
(auth != null && query.orderByChild == 'status' && query.equalTo == 'completeness_tutorial' && query.limitToFirst == 1)
||
// only team members can query by their own teamId
(auth != null && query.orderByChild == 'teamId' &&
query.equalTo == root.child('/v2/users/'+auth.uid+'/teamId').val())
||
// project managers can read all
(auth.token.projectManager === true)
",
"$project_id": {
// project managers can read/write all attributes
".write": "auth.token.projectManager === true",
".read": "
// all users can read all public projects
(data.child('teamId').exists() == false)
||
// team members can read their projects
(data.child('teamId').val() == root.child('/v2/users/'+auth.uid+'/teamId').val())
"
},
".indexOn": [
"status",
"isFeatured",
"teamId",
"projectTopicKey"
]
},
"projectDrafts": {
// only project managers can write projectDrafts
".read": false,
".write": "auth.token.projectManager === true",
".indexOn": [
"complete"
]
},
"tutorialDrafts": {
// only project managers can write projectDrafts
".read": false,
".write": "auth.token.projectManager === true",
".indexOn": [
"complete"
]
},
"groups": {
".write": false,
".read": "auth.token.projectManager === true",
"$project_id": {
".read": "
// everyone can read groups for public projects
(root.child('/v2/projects/'+$project_id).hasChild('teamId') === false)
||
(root.child('/v2/projects/'+$project_id+'/teamId').val() ==
root.child('/v2/users/'+auth.uid+'/teamId').val())
",
".indexOn": [
"finishedCount",
"requiredCount"
]
}
},
"tasks": {
".write": false,
".read": "auth.token.projectManager === true",
"$project_id": {
".read": "
// everyone can read groups for public projects
(root.child('/v2/projects/'+$project_id).hasChild('teamId') === false)
||
(root.child('/v2/projects/'+$project_id+'/teamId').val() ==
root.child('/v2/users/'+auth.uid+'/teamId').val())
"
},
},
"teams": {
".write": false,
// project managers can read all attributes
".read": "auth.token.projectManager === true",
"$teamId": {
".write": "auth.token.projectManager === true",
"teamName": {
// team members read teamName
".read": "(root.child('/v2/users/'+auth.uid+'/teamId').val() === $teamId)"
//".read": "auth != null"
},
".indexOn": [
"teamName"
]
}
},
"results": {
".write": false,
".read": false,
"$project_id": {
"$group_id": {
"$uid": {
".write": "
// everyone can write results for public projects
(root.child('/v2/projects/'+$project_id).hasChild('teamId') === false &&
auth.uid == $uid
)
||
(root.child('/v2/projects/'+$project_id+'/teamId').val() ==
root.child('/v2/users/'+auth.uid+'/teamId').val() &&
auth.uid == $uid
)
"
}
}
}
},
"users": {
".read": true,
".write": false,
"$uid": {
"teamId": {
".write": false
},
"$other": {
".write": "auth != null && auth.uid == $uid"
}
},
"userGroups": {
".write": "auth != null"
},
".indexOn": [
"created",
"teamId",
"usernameKey"
]
},
"OSMAccessToken": {
"$uid": {
".read": "auth.uid === $uid",
".write": "auth.uid === $uid"
}
},
"userGroups": {
".write": false,
".read": "auth != null",
"$usergroup_id": {
// Project managers can create new User Groups
".write": "auth.token.projectManager === true",
"users": {
// Logged in users can join group
".write": "auth != null"
}
},
".indexOn": [
"nameKey",
],
},
"organisations": {
".write": "auth.token.projectManager === true",
".read": "auth != null",
".indexOn": [
"nameKey",
],
},
"userGroupMembershipLogs": {
".write": "auth != null",
".read": "auth != null"
}
},
// leaving this here, since version before v2 pull data from there
"users": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
}
}
}