-
Notifications
You must be signed in to change notification settings - Fork 36
/
database2.rules.json
105 lines (102 loc) · 7.85 KB
/
database2.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
{
"rules": {
"users": {
"$secretid": {
".read": "$secretid == auth.uid",
".write": "auth.uid == $secretid",
".indexOn": "lastAccessTime"
}
},
"$secretid": {
".write": "!root.child($secretid).exists()",
"users": {
".read": "root.child($secretid).child('settings').child('defaultPermission').val() !== 'PRIVATE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ'",
"$user": {
".read": "$user === auth.uid",
".write": "(auth.uid === $user && !root.child($secretid).child('settings').child('users').exists()) || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || (auth.uid === $user && data.child('permission').val() === newData.child('permission').val())"
}
},
"editor-cpp": {
".read": "root.child($secretid).child('settings').child('defaultPermission').val() !== 'PRIVATE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ'",
".write": "root.child($secretid).child('settings').child('defaultPermission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE'",
"history": {
"$revision": {
/* Prevent overwriting existing revisions. */
".validate": "data.val() === null || newData.val() === null"
}
},
"checkpoint": {
/* Ensure author of checkpoint is the same as the author of the revision they're checkpointing. */
".validate": "!root.child($secretid).exists() || root.child($secretid).child('editor-cpp').child('history').child(newData.child('id').val()).child('a').val() === newData.child('a').val() && newData.hasChildren(['a', 'o', 'id'])"
}
},
"editor-java": {
".read": "root.child($secretid).child('settings').child('defaultPermission').val() !== 'PRIVATE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ'",
".write": "root.child($secretid).child('settings').child('defaultPermission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE'",
"history": {
"$revision": {
/* Prevent overwriting existing revisions. */
".validate": "data.val() === null || newData.val() === null"
}
},
"checkpoint": {
/* Ensure author of checkpoint is the same as the author of the revision they're checkpointing. */
".validate": "!root.child($secretid).exists() || root.child($secretid).child('editor-java').child('history').child(newData.child('id').val()).child('a').val() === newData.child('a').val() && newData.hasChildren(['a', 'o', 'id'])"
}
},
"editor-py": {
".read": "root.child($secretid).child('settings').child('defaultPermission').val() !== 'PRIVATE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ'",
".write": "root.child($secretid).child('settings').child('defaultPermission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE'",
"history": {
"$revision": {
/* Prevent overwriting existing revisions. */
".validate": "data.val() === null || newData.val() === null"
}
},
"checkpoint": {
/* Ensure author of checkpoint is the same as the author of the revision they're checkpointing. */
".validate": "!root.child($secretid).exists() || root.child($secretid).child('editor-py').child('history').child(newData.child('id').val()).child('a').val() === newData.child('a').val() && newData.hasChildren(['a', 'o', 'id'])"
}
},
"input": {
".read": "root.child($secretid).child('settings').child('defaultPermission').val() !== 'PRIVATE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ'",
".write": "root.child($secretid).child('settings').child('defaultPermission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE'",
"history": {
"$revision": {
/* Prevent overwriting existing revisions. */
".validate": "data.val() === null || newData.val() === null"
}
},
"checkpoint": {
/* Ensure author of checkpoint is the same as the author of the revision they're checkpointing. */
".validate": "!root.child($secretid).exists() || root.child($secretid).child('input').child('history').child(newData.child('id').val()).child('a').val() === newData.child('a').val() && newData.hasChildren(['a', 'o', 'id'])"
}
},
"settings": {
".read": true,
"$setting": {
".write": "!root.child($secretid).child('settings').child('defaultPermission').exists() || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE'"
},
"defaultPermission": {
".write": "!root.child($secretid).child('settings').child('defaultPermission').exists() || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER'"
},
"creationTime": {
/* only write upon creation */
".write": "!root.child($secretid).child('settings').child('creationTime').exists()"
}
},
"chat": {
".read": "root.child($secretid).child('settings').child('defaultPermission').val() !== 'PRIVATE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ'",
".write": "root.child($secretid).child('settings').child('defaultPermission').val() === 'READ_WRITE' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER' || root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'READ_WRITE'"
},
"classroom": {
".read": true,
"$setting": {
".write": "root.child($secretid).child('users').child(auth.uid).child('permission').val() === 'OWNER'"
}
}
},
".read": false,
".write": false
}
}