-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfirestore.rules
37 lines (34 loc) · 1009 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isSignedIn() {
return request.auth.uid != null;
}
function isSnippetOwner() {
return resource.data.owner == request.auth.uid;
}
function isPublic() {
return resource.data.visibility == 'public';
}
function isUnlisted() {
return resource.data.visibility == 'unlisted';
}
function isLiker() {
return resource.data.userID == request.auth.uid;
}
match /users/{user} {
allow read, write: if isSignedIn() && user == request.auth.uid;
}
match /snippets/{snippet} {
allow read: if isPublic() || isUnlisted() || (isSignedIn() && isSnippetOwner());
allow create: if true;
allow update, delete: if isSignedIn() && isSnippetOwner();
}
match /likes/{like} {
// Likes are public info
allow read: if true;
allow create: if isSignedIn();
allow update, delete: if isLiker();
}
}
}