-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
executable file
·93 lines (83 loc) · 2.74 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
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
service cloud.firestore {
match /databases/{database}/documents {
match /tester/{document=**} {
allow read, write;
}
match /testers {
allow read: if request.auth != null;
match /{demosID} {
// allow read: if resource.data.keys().hasAll(['users.$(request.auth.uid)'])
// allow read: if request.resource.data.users. is int;
// allow read: if request.resource.data.users.keys().hasAll([request.auth.uid]);
// allow read: if request.resource.data.users.keys().hasAll(['$(request.auth.uid)']);
// allow read: if exists(/databases/$(database)/documents/chat/$(document)/users/$(request.auth.uid));
// allow read: if request.resource.data.users[request.auth.uid] is bool;
allow read: if resource.data.users.keys().hasAll([request.auth.uid]);
}
}
match /user {
allow create: if request.auth != null;
match /{userID} {
allow read;
// TODO: replace with function that checks user's role
allow write, create: if request.auth.uid == userID;
}
allow create: if request.auth != null;
allow read;
}
match /ping {
allow create: if request.auth != null;
match /{userID} {
allow read;
// TODO: replace with function that checks user's role
allow write, create: if request.auth.uid == userID;
}
allow create: if request.auth != null;
allow read;
}
match /connection-invite {
match /{document=**} {
allow read;
// TODO: replace with function that checks user's role
allow write: if request.auth != null;
}
}
// Reads are divided into get and list operations
// allow get, list: if <condition>;
function isOnChatUsers(chatID) {
return request.auth.uid in get(/databases/$(database)/documents/chat/$(chatID)).data.users;
}
match /chat {
// allow read, get, list;
allow create: if request.auth != null;
match /{chatID} {
allow write, read, update: if isOnChatUsers(chatID);
allow get, list, create: if request.auth != null;
}
}
match /chat-message {
// allow create: if isOnChatUsers(request.resource.data.group);
match /{messageId} {
// allow read, get, list: if isOnChatUsers(resource.data.group);
allow read;
allow write: if isOnChatUsers(request.resource.data.group);
allow create: if isOnChatUsers(request.resource.data.group);
}
}
match /notes {
allow read;
match /{noteId} {
allow read;
allow write: if request.auth != null;
}
}
match /demo {
allow read;
match /{demoId} {
allow read;
allow write;
}
}
// End
}
}