-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
37 lines (32 loc) · 1.07 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// All users should be allowed to access disaster metadata, since mapping
// page is globally accessible.
match /disaster-metadata/{document=**} {
allow read: if true;
}
// Only specific users can access usershapes, since that has potentially
// sensitive entered data.
match /usershapes/{docname} {
allow read, write: if inUserDatabase();
}
// Disaster metadata can only be written by admin user.
match /disaster-metadata/{document=**} {
allow write: if isAdminUser();
}
function inUserDatabase() {
return hasEmail()
&& request.auth.token.email in
get(/databases/$(database)/documents/ALLOWED_USERS/ALL_USERS).data.USERS;
}
function isAdminUser() {
return hasEmail()
&& request.auth.token.email == 'gd-earthengine-user@givedirectly.org';
}
function hasEmail() {
return request.auth != null && request.auth.token != null
&& request.auth.token.email != null;
}
}
}