-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfirestore.rules
More file actions
116 lines (98 loc) · 3.69 KB
/
Copy pathfirestore.rules
File metadata and controls
116 lines (98 loc) · 3.69 KB
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function signedIn() {
return request.auth != null;
}
function verifiedEmail() {
return signedIn() && request.auth.token.email_verified == true;
}
function isAdmin() {
return verifiedEmail() &&
exists(/databases/$(database)/documents/users/$(request.auth.uid)) &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin == true;
}
function isConversationParticipant() {
return verifiedEmail() && request.auth.uid in resource.data.participantIds;
}
function isConversationParticipantById(conversationId) {
return verifiedEmail() &&
exists(/databases/$(database)/documents/conversations/$(conversationId)) &&
request.auth.uid in
get(/databases/$(database)/documents/conversations/$(conversationId))
.data.participantIds;
}
function hasNoAdminFieldOnCreate() {
return !(request.resource.data.keys().hasAny(["admin"]));
}
match /users/{userId} {
allow read: if signedIn();
allow create: if signedIn() &&
request.auth.uid == userId &&
request.resource.data.uid == userId &&
hasNoAdminFieldOnCreate();
allow update: if signedIn() &&
request.auth.uid == userId &&
request.resource.data.uid == userId &&
!(request.resource.data.diff(resource.data).affectedKeys().hasAny(["admin"]));
allow delete: if false;
match /timetable/{entryId} {
allow read: if signedIn() && request.auth.uid == userId;
allow create, update, delete: if verifiedEmail() && request.auth.uid == userId;
}
match /eventSignups/{eventId} {
allow read: if signedIn() && request.auth.uid == userId;
allow create, update, delete: if verifiedEmail() && request.auth.uid == userId;
}
}
match /collaborations/{collaborationId} {
allow read: if true;
allow create: if verifiedEmail() &&
request.resource.data.authorId == request.auth.uid &&
request.resource.data.title is string &&
request.resource.data.description is string &&
request.resource.data.tags is list;
allow update, delete: if verifiedEmail() &&
(resource.data.authorId == request.auth.uid || isAdmin());
}
match /events/{eventId} {
allow read: if true;
allow create, update, delete: if isAdmin();
}
match /eventProposals/{proposalId} {
allow read: if signedIn() &&
(resource.data.authorId == request.auth.uid || isAdmin());
allow create: if verifiedEmail() &&
request.resource.data.authorId == request.auth.uid &&
request.resource.data.name is string &&
request.resource.data.status == "pending";
allow update, delete: if isAdmin();
}
match /feedback/{feedbackId} {
allow read: if false;
allow create: if false;
allow update, delete: if false;
}
match /polls/{pollId} {
allow read: if isAdmin() ||
resource.data.status == "live" ||
resource.data.status == "closed";
allow create, update, delete: if false;
match /votes/{voteId} {
allow read: if isAdmin() || (verifiedEmail() && voteId == request.auth.uid);
allow create, update, delete: if false;
}
}
match /conversations/{conversationId} {
allow read: if isConversationParticipant();
allow create, update, delete: if false;
match /messages/{messageId} {
allow read: if isConversationParticipantById(conversationId);
allow create, update, delete: if false;
}
}
match /{document=**} {
allow read, write: if false;
}
}
}