forked from retoruto-carry/shindan-chart-maker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
65 lines (57 loc) · 1.78 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read;
}
match /users {
match /{userId} {
allow write:if true
&& request.auth.uid == userId
&& validateString(incomingData().displayName, 0, 512)
&& validateString(incomingData().photoUrl, 0, 512)
&& validateString(incomingData().username, 0, 512)
;
}
}
match /posts {
match /{postId} {
allow create: if true
&& request.auth.uid == incomingData().userId
&& validateString(incomingData().title, 0, 512)
&& validateString(incomingData().subtitle, 0, 512)
&& validateString(incomingData().hashtag, 0, 140)
&& validateString(incomingData().nodeTree, 0, 16384)
;
allow update: if true
&& request.auth.uid == existingData().userId
&& request.auth.uid == incomingData().userId
&& validateString(incomingData().title, 0, 512)
&& validateString(incomingData().subtitle, 0, 512)
&& validateString(incomingData().nodeTree, 0, 16384)
&& incomingData().createdAt == existingData().createdAt
allow delete: if request.auth.uid == existingData().userId
;
}
}
match /tags {
match /{tagId} {
allow write: if true
&& isUserAuthenticated()
&& validateString(incomingData().text, 0, 512)
}
}
}
function incomingData() {
return request.resource.data;
}
function existingData() {
return resource.data;
}
function validateString(text, min, max) {
return text is string && min <= text.size() && text.size() <= max;
}
function isUserAuthenticated() {
return request.auth != null;
}
}