-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
39 lines (32 loc) · 918 Bytes
/
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth.uid != null
}
function isAdmin() {
return isAuthenticated() &&
'role' in request.auth.token &&
request.auth.token.role == 'admin'
}
function isOwner(userId) {
return isAuthenticated() &&
userId == request.auth.uid
}
// Equivalent, more specific
// match /inventories/{userId}/items/{itemId} {
match /inventories/{userId}/{doc=**} {
allow read, write: if isOwner(userId);
}
// Equivalent, more specific
// match /lists/{userId}/items/{itemId}
match /lists/{userId}/{doc=**} {
allow read, write: if isOwner(userId);
}
match /invites/{inviteId} {
allow read: if true;
allow create: if isAdmin();
allow delete: if isAuthenticated();
}
}
}