-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
184 lines (149 loc) · 4.34 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
rules_version = '2';
service cloud.firestore {
function authenticated() {
return request.auth.token != null;
}
function admin() {
return authenticated() && request.auth.token.role == 'admin';
}
match /databases/{database}/documents {
match /admins/{adminId} {
allow get: if adminId == request.auth.uid || admin();
allow list: if admin();
allow update: if (
adminId == request.auth.uid &&
!request.resource.data.diff(resource.data).affectedKeys().hasAny(['role', 'createdOn'])
) || admin();
allow delete: if adminId == request.auth.uid || admin();
}
match /users/{userId} {
allow get: if userId == request.auth.uid || admin();
allow list: if admin();
allow update: if admin();
allow delete: if userId == request.auth.uid || admin();
}
match /releases/{releaseId} {
allow write, read: if admin();
}
match /release-history/{releaseId} {
allow write, read: if admin();
}
match /coupons/{document=**} {
allow read: if true;
allow write: if admin();
}
match /customers/{customer} {
allow read: if admin() || ((authenticated() && request.auth.uid == customer));
// TODO: Allow only updating of some fields
allow write: if admin() || ((authenticated() && request.auth.uid == customer));
}
match /products/{document=**} {
allow read: if true;
allow write: if admin();
match /reviews/{review} {
allow read: if true;
allow write: if admin();
}
}
match /blog-articles/{document} {
allow read: if true;
allow write: if admin();
match /blog-comments/{comment} {
allow list: if true || admin();
allow get: if admin();
allow create: if admin() || (
authenticated() &&
request.resource.data.author == request.auth.uid &&
request.resource.data.keys().hasOnly(
['author', 'authorName', 'comment', 'createdOn']
)
);
allow update: if admin() || (
request.resource.data.author == request.auth.uid &&
request.resource.data.diff(resource.data).affectedKeys().hasOnly(['comment', 'authorName'])
);
allow delete: if admin() || (resource.data.author == request.auth.uid);
}
}
match /blog-categories/{document} {
allow read: if true;
allow write: if admin();
}
match /blog-authors/{document} {
allow read: if true;
allow write: if admin();
}
match /email-templates/{document=**} {
allow read, write: if admin();
}
match /email-template-layouts/{document=**} {
allow read, write: if admin();
}
match /tags/{document} {
allow read: if true;
allow write: if admin();
}
match /products/{document} {
allow read: if true;
allow write: if admin();
}
match /coupons/{document} {
allow read: if admin()
allow write: if admin();
}
match /discounts/{document} {
allow read: if true;
allow write: if admin();
}
match /orders/{document} {
allow read: if admin() || (authenticated() && request.auth.uid == resource.data.customer);
allow write: if admin();
}
match /categories/{document} {
allow read: if true;
allow write: if admin();
}
match /pages/{id=**} {
allow read: if true;
allow write: if admin();
}
match /sections/{id=**} {
allow read: if true;
allow write: if admin();
}
match /templates/{id=**} {
allow read: if true;
allow write: if admin();
}
match /popups/{id=**} {
allow read: if true;
allow write: if admin();
}
match /layouts/{id=**} {
allow read: if true;
allow write: if admin();
}
match /notification-channels/{id=**} {
allow read: if admin();
allow write: if admin();
}
match /cms-notifications/{id=**} {
allow read: if admin();
allow write: if admin();
}
match /notifications/{id=**} {
allow read: if admin();
allow write: if admin();
}
match /forms/{form} {
allow read, write: if admin();
match /form-responses/{id} {
allow read: if admin();
allow write: if true;
}
}
match /{document=**} {
allow read, write: if false;
}
}
}