-
Notifications
You must be signed in to change notification settings - Fork 1
/
firestore.rules
48 lines (40 loc) · 1.37 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Custom functions
function signedIn() {
return request.auth != null;
}
function isAdmin() {
return signedIn() &&
'ADMIN'in get(/databases/$(database)/documents/users/$(request.auth.uid)).data.roles.values();
}
function isOwner() {
return signedIn() && request.auth.uid == resource.data.userId;
}
function isSelf() {
return signedIn() && request.auth.uid == resource.id;
}
// Rules
match /users/{userId} {
allow list: if isAdmin();
allow get, set, update, delete: if isSelf() || isAdmin();
allow create: if signedIn();
}
match /dashboards/{dashboardId} {
allow read: if signedIn();
allow create: if signedIn() && request.resource.data.userId == request.auth.uid;
allow update, delete: if signedIn() && isOwner();
}
match /tabs/{tabId} {
allow read: if signedIn();
allow create: if signedIn() && request.resource.data.userId == request.auth.uid;
allow update, delete: if signedIn() && isOwner();
}
match /feeds/{feedId} {
allow read: if signedIn();
allow create: if signedIn() && request.resource.data.userId == request.auth.uid;
allow update, delete: if signedIn() && isOwner();
}
}
}