-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathfirestore.rules
32 lines (29 loc) · 869 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
service cloud.firestore {
match /databases/{database}/documents {
function isAuthed() {
return request.auth.uid != null
}
function isOwner(res) {
return res.data.createdBy == request.auth.uid
}
// Private user profiles
match /users/{userId} {
allow read;
allow write: if request.auth.uid == userId;
}
// Public user profiles
match /users_public/{userId} {
allow read;
allow write: if false; // only written to by indexUser cloud function
}
// Projects
match /projects/{projectId} {
// Only projects you own can be viewed
allow read, write: if isOwner(request.resource);
// Rules apply to all child collections
match /{allChildren=**} {
allow read, write: if isOwner(get(/databases/$(database)/documents/projects/$(projectId)));
}
}
}
}