This repository has been archived by the owner on Apr 12, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathfirestore.rules
58 lines (47 loc) · 1.89 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
service cloud.firestore {
match /databases/{database}/documents {
function isSignedIn() {
return request.auth.uid != null;
}
match /users/{user} {
allow create: if isSignedIn();
allow get: if isSignedIn();
allow list: if isSignedIn() && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin;
allow update, delete: if isSignedIn() && request.auth.uid == resource.data.uid;
match /logins/{login} {
allow read, write: if isSignedIn() && get(/databases/$(database)/documents/users/$(user)).data.uid == request.auth.uid;
}
}
match /userStats/{user} {
allow create, update: if isSignedIn();
allow get, list: if true;
}
match /projects/{project} {
allow create: if isSignedIn();
allow get, list: if resource.data.type == 'public' || (isSignedIn() && (request.auth.uid in resource.data.access.admin || request.auth.uid in resource.data.access.readonly));
allow update, delete: if isSignedIn() && request.auth.uid in resource.data.access.admin;
function projectDoc() {
return get(/databases/$(database)/documents/projects/$(project)).data
}
match /pings/{ping} {
allow create: if isSignedIn();
allow get, list: if resource.data.type == 'public' || request.auth.uid in projectDoc().access.admin || request.auth.uid in projectDoc().access.readonly;
allow update, delete: if isSignedIn() && request.auth.uid in projectDoc().access.admin;
}
}
match /repositories/{repository} {
allow create: if false;
allow get: if resource.data.private == false;
allow list: if false;
allow update: if false;
allow delete: if false;
}
match /platform/stats {
allow create: if false;
allow get: if true;
allow list: if false;
allow update: if false;
allow delete: if false;
}
}
}