-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfirestore.rules
More file actions
126 lines (102 loc) · 3.59 KB
/
Copy pathfirestore.rules
File metadata and controls
126 lines (102 loc) · 3.59 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
117
118
119
120
121
122
123
124
125
126
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isSignedIn() {
return request.auth.uid != null;
}
function hasRole(role) {
let roles = {"admin": 1, "writer": 2, "member": 3};
return isSignedIn() && roles[role] in get(/databases/$(database)/documents/sensitive-user-data/$(request.auth.token.email)).data.roles;
}
function isDataOwner() {
return resource.data.uID == request.auth.uid;
}
function isEmailVerified() {
return request.auth.token.email_verified == true;
}
match /blog-entries/{document=**} {
allow read: if resource.data.listed == true || hasRole("writer") || hasRole("admin");
allow write: if hasRole("writer") || hasRole("admin");
}
// cada student accede solo a su propia informacion
match /events/{eventId}/students/{userEmail} {
allow read, write:
if isSignedIn() && request.auth.token.email == userEmail;
}
match /events/{document=**} {
allow read;
allow write: if hasRole("admin");
}
/*match /events/{eventId}/user_exams/{examId=**} {
allow read;
allow write;
}*/
match /collection-metadata/{document=**} {
allow read;
allow write: if hasRole("admin");
}
match /team/{document=**} {
allow read;
allow write: if hasRole("admin");
}
match /team-requests/{document=**} {
allow read: if hasRole("admin");
allow write: if isEmailVerified() || hasRole("admin");
}
match /commissions/{document=**} {
allow read;
allow write: if hasRole("admin");
}
match /{path=**}/members/{member} {
allow read;
allow write: if hasRole("admin") || hasRole("member");
}
match /users/{document=**} {
allow get, update, delete: if isDataOwner() || hasRole("admin");
allow list: if hasRole("admin");
// Solo puede crear el objeto usuario si el id del usuario en el body corresponde con el id del usuario en el token
allow create: if (isSignedIn() && request.resource.data.uID == request.auth.uid) || hasRole("admin");
}
match /sensitive-user-data/{document=**} {
allow read, write: if hasRole("admin");
}
// Asimov
match /asimov-robots/{document=**} {
allow read;
allow write: if hasRole("admin");
}
match /asimov-categories/{document=**} {
allow read;
allow write: if hasRole("admin");
}
match /asimov-scores/{score} {
allow read;
allow write;
// TODO: multiple-categories refactor needed
// allow write: if get(/databases/$(database)/documents/collection-metadata/asimov-scores).data.open || hasRole("admin");
}
match /{path=**}/predictions/{prediction} {
allow read;
}
match /asimov-scores/{userId}/predictions/{predictionId} {
allow read;
// Solo se pueden crear predicciones si la categoria especifica esta abierta.
allow write: if (isSignedIn() && request.auth.uid == userId
&& get(/databases/$(database)/documents/asimov-categories/$(request.resource.data.category.id)).data.predictionsOpen == true)
|| hasRole("admin");
}
match /asimov-encounters/{document=**} {
allow read;
allow write: if hasRole("admin");
}
match /ieeextreme-teams/{document=**} {
allow read: if true;
allow write: if hasRole("admin");
}
match /{path=**}/comments/{comment} {
allow read;
allow create: if isSignedIn();
allow delete: if hasRole("admin") || hasRole("writer") || isDataOwner();
}
}
}