@@ -10,14 +10,8 @@ service cloud.firestore {
1010 // Ownership rules
1111 request .auth.uid == userId
1212 ;
13- allow create : if
14- // Ownership rules
15- request .auth.uid == userId
16- ;
17- allow update : if
18- // Ownership rules
19- request .auth.uid == userId
20- ;
13+ allow create : if true ;
14+ allow update : if true ;
2115 allow delete : if
2216 // Ownership rules
2317 request .auth.uid == userId
@@ -44,5 +38,211 @@ service cloud.firestore {
4438 ;
4539 }
4640 }
41+ match / sharedList/ {sharedList } {
42+ allow list : if
43+ // Permission rules
44+ true
45+ ;
46+ allow get : if
47+ // Permission rules
48+ true
49+ ;
50+ allow create : if
51+ // Type checks
52+ request .resource.data.createdWhen is timestamp &&
53+ request .resource.data.updatedWhen is timestamp &&
54+ request .resource.data.title is string &&
55+ (! (' description' in request .resource.data .keys ()) || request .resource.data.description is string ) &&
56+
57+
58+ // Ownership rules
59+ request .auth.uid == request .resource.data.creator
60+ ;
61+ allow update : if
62+ // Type checks
63+ request .resource.data.createdWhen is timestamp &&
64+ request .resource.data.updatedWhen is timestamp &&
65+ request .resource.data.title is string &&
66+ (! (' description' in request .resource.data .keys ()) || request .resource.data.description is string ) &&
67+
68+
69+ // Ownership rules
70+ request .auth.uid == resource.data.creator && (request .auth.uid == request .resource.data.creator || (! (' creator' in request .resource.data .keys ())))
71+ ;
72+ allow delete : if
73+ // Ownership rules
74+ request .auth.uid == resource.data.creator
75+ ;
76+ }
77+ match / sharedListCreatorInfo/ {creator } {
78+ match / lists/ {sharedListCreatorInfo } {
79+ allow list : if
80+ // Permission rules
81+ true
82+ ;
83+ allow get : if
84+ // Permission rules
85+ true
86+ ;
87+ allow create : if
88+ // Type checks
89+ request .resource.data.localListId is timestamp &&
90+
91+
92+ // Ownership rules
93+ request .auth.uid == creator
94+ ;
95+ allow update : if
96+ // Type checks
97+ request .resource.data.localListId is timestamp &&
98+
99+
100+ // Ownership rules
101+ request .auth.uid == creator
102+ ;
103+ allow delete : if
104+ // Ownership rules
105+ request .auth.uid == creator
106+ ;
107+ }
108+ }
109+ match / sharedListEntry/ {sharedListEntry } {
110+ allow list : if
111+ // Permission rules
112+ true
113+ ;
114+ allow get : if
115+ // Permission rules
116+ true
117+ ;
118+ allow create : if
119+ // Type checks
120+ request .resource.data.createdWhen is timestamp &&
121+ request .resource.data.updatedWhen is timestamp &&
122+ request .resource.data.entryTitle is string &&
123+ request .resource.data.normalizedUrl is string &&
124+ request .resource.data.originalUrl is string &&
125+
126+
127+ // Ownership rules
128+ request .auth.uid == request .resource.data.creator
129+ ;
130+ allow update : if
131+ // Type checks
132+ request .resource.data.createdWhen is timestamp &&
133+ request .resource.data.updatedWhen is timestamp &&
134+ request .resource.data.entryTitle is string &&
135+ request .resource.data.normalizedUrl is string &&
136+ request .resource.data.originalUrl is string &&
137+
138+
139+ // Ownership rules
140+ request .auth.uid == resource.data.creator && (request .auth.uid == request .resource.data.creator || (! (' creator' in request .resource.data .keys ())))
141+ ;
142+ allow delete : if
143+ // Ownership rules
144+ request .auth.uid == resource.data.creator
145+ ;
146+ }
147+ match / sharedAnnotation/ {sharedAnnotation } {
148+ allow list : if
149+ // Permission rules
150+ true
151+ ;
152+ allow get : if
153+ // Permission rules
154+ true
155+ ;
156+ allow create : if
157+ // Type checks
158+ request .resource.data.normalizedPageUrl is string &&
159+ request .resource.data.createdWhen is timestamp &&
160+ request .resource.data.uploadedWhen is timestamp &&
161+ request .resource.data.updatedWhen is timestamp &&
162+ (! (' body' in request .resource.data .keys ()) || request .resource.data.body is string ) &&
163+ (! (' comment' in request .resource.data .keys ()) || request .resource.data.comment is string ) &&
164+ (! (' selector' in request .resource.data .keys ()) || request .resource.data.selector is string ) &&
165+
166+
167+ // Ownership rules
168+ request .auth.uid == request .resource.data.creator
169+ ;
170+ allow update : if
171+ // Type checks
172+ request .resource.data.normalizedPageUrl is string &&
173+ request .resource.data.createdWhen is timestamp &&
174+ request .resource.data.uploadedWhen is timestamp &&
175+ request .resource.data.updatedWhen is timestamp &&
176+ (! (' body' in request .resource.data .keys ()) || request .resource.data.body is string ) &&
177+ (! (' comment' in request .resource.data .keys ()) || request .resource.data.comment is string ) &&
178+ (! (' selector' in request .resource.data .keys ()) || request .resource.data.selector is string ) &&
179+
180+
181+ // Ownership rules
182+ request .auth.uid == resource.data.creator && (request .auth.uid == request .resource.data.creator || (! (' creator' in request .resource.data .keys ())))
183+ ;
184+ allow delete : if
185+ // Ownership rules
186+ request .auth.uid == resource.data.creator
187+ ;
188+ }
189+ match / sharedAnnotationListEntry/ {sharedAnnotationListEntry } {
190+ allow list : if
191+ // Permission rules
192+ true
193+ ;
194+ allow get : if
195+ // Permission rules
196+ true
197+ ;
198+ allow create : if
199+ // Type checks
200+ request .resource.data.createdWhen is timestamp &&
201+ request .resource.data.uploadedWhen is timestamp &&
202+ request .resource.data.updatedWhen is timestamp &&
203+ request .resource.data.normalizedPageUrl is string &&
204+
205+
206+ // Ownership rules
207+ request .auth.uid == request .resource.data.creator
208+ ;
209+ allow update : if
210+ // Type checks
211+ request .resource.data.createdWhen is timestamp &&
212+ request .resource.data.uploadedWhen is timestamp &&
213+ request .resource.data.updatedWhen is timestamp &&
214+ request .resource.data.normalizedPageUrl is string &&
215+
216+
217+ // Ownership rules
218+ request .auth.uid == resource.data.creator && (request .auth.uid == request .resource.data.creator || (! (' creator' in request .resource.data .keys ())))
219+ ;
220+ allow delete : if
221+ // Ownership rules
222+ request .auth.uid == resource.data.creator
223+ ;
224+ }
225+ match / user/ {id } {
226+ allow get : if
227+ // Permission rules
228+ true
229+ ;
230+ allow create : if
231+ // Type checks
232+ (! (' displayName' in request .resource.data .keys ()) || request .resource.data.displayName is string ) &&
233+
234+
235+ // Ownership rules
236+ request .auth.uid == id
237+ ;
238+ allow update : if
239+ // Type checks
240+ (! (' displayName' in request .resource.data .keys ()) || request .resource.data.displayName is string ) &&
241+
242+
243+ // Ownership rules
244+ request .auth.uid == id
245+ ;
246+ }
47247 }
48248}
0 commit comments