-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
35 lines (30 loc) · 1.18 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Allow read access to all documents
match /{document=**} {
allow read: if true;
}
// Allow write access only to authenticated users for their own data in the "users" collection
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Allow write access only to authenticated users for the "posts" collection
match /posts/{postId} {
allow write: if request.auth != null;
allow delete: if request.auth != null && request.auth.uid == resource.data.postedBy;
}
// Allow read and write access to comments for authorized users.
match /posts/{postId}/comments/{commentId} {
allow read, write: if request.auth != null;
}
// Allow write access only to authenticated users for the "reports" collection
match /reports/{reportId} {
allow write: if request.auth != null;
}
// Allow read and write access to notifications for authorized users.
match /users/{userId}/notifications/{notificationId} {
allow read, write: if request.auth != null;
}
}
}