-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
firestore.rules
54 lines (51 loc) · 2.03 KB
/
firestore.rules
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
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
// This function allows us to look at AuthZ (Authorization) roles within our database, to see who is allowed for activities.
function getRole(role) {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.roles[role]
}
// Users
match /users/{userId} {
allow read: if request.auth.uid != null;
allow create: if request.resource.data.roles.keys().hasAny(['admin', 'editor']) == false;
allow update: if request.resource.data.roles.keys().hasAny(['admin', 'editor']) == false
|| resource.data.roles.keys().hasAny(['admin', 'editor']) == true;
}
match /config/{configId}{
allow read: if true;
}
match /books/{bookId}{
allow create: if getRole('admin') == true;
allow read: if true;
allow update: if getRole('editor') == true || getRole('admin') == true;
allow delete: if getRole('admin') == true;
match /chapters/{chapterId}{
allow create: if getRole('admin') == true;
allow read: if true;
allow update: if getRole('editor') == true || getRole('admin') == true;
allow delete: if getRole('admin') == true;
match /pages/{pageId}{
allow create: if getRole('admin') == true;
allow read: if true;
allow update: if getRole('editor') == true || getRole('admin') == true;
allow delete: if getRole('admin') == true;
}
}
}
match /authors/{authorId}{
allow create: if getRole('admin') == true;
allow read: if true;
allow update: if getRole('editor') == true || getRole('admin') == true;
allow delete: if getRole('admin') == true;
}
match /graphicnovels/{gnId}{
allow create: if getRole('admin') == true;
allow read: if true;
allow update: if getRole('editor') == true || getRole('admin') == true;
allow delete: if getRole('admin') == true;
}
}
}