-
Notifications
You must be signed in to change notification settings - Fork 4
/
firebase-rules.json
51 lines (51 loc) · 2.29 KB
/
firebase-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
{
"rules": {
"users": {
"$userid": {
"profile": {
".read": true,
".write": "$userid == auth.uid && auth.uid != null"
},
"notebooks": {
".read": "$userid == auth.uid && auth.uid != null",
"$secretid": {
// read only by editors when sharing/isPrivate == true
".read": "(data.child('meta/sharing/isPrivate').exists() == false) || (data.child('meta/sharing/isPrivate').val() == false) || (data.child('meta/sharing/isPrivate').val() == true && $userid == auth.uid) || ($userid == 'anonymous') || (data.child('meta/sharing/publicRead').val() == true)",
// write by editors || everyone if anonymous
".write": "(data.child('meta/sharing/isPrivate').exists() == false) || (data.child('meta/sharing/isPrivate').val() == false) || ($userid == auth.uid && auth.uid != null) || ($userid == 'anonymous')",
"meta": {
"sharing": {
// only the owner can set the document public/private
".write": "$userid == auth.uid && auth.uid != null",
".validate": "newData.hasChildren(['isPrivate', 'publicRead'])"
},
// NOTE: this should not exist. it is part of the path
"uid": {
".validate": "!data.exists() && auth.uid != null && auth.uid == newData.val()"
},
"title": {
".validate": "newData.isString() && newData.val().length > 0"
}
},
"history": {
"$revision": {
/* Prevent overwriting existing revisions. */
".validate": "data.val() === null"
}
},
"checkpoint": {
/* Ensure author of checkpoint is the same as the author of the revision they're checkpointing. */
".write": "root.child('users/' + $userid + '/notebooks/' + $secretid).child('history').child( newData.child('id').val() ).child('a').val() === newData.child('a').val()",
".validate": "newData.hasChildren(['a', 'o', 'id'])"
},
"users": {
"$user": {
".write": "(auth != null && ($user == auth.uid)) || auth == null"
}
}
}
}
}
}
}
}