-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
40 lines (35 loc) · 1.3 KB
/
firestore.rules
File metadata and controls
40 lines (35 loc) · 1.3 KB
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAdmin() {
return request.auth != null
&& request.auth.token.email != null
&& request.auth.token.email.matches('.*@snapsign\\.com\\.au$');
}
// Admin config documents (written by the admin portal)
match /admin/{docId} {
allow read, create, update, delete: if isAdmin();
}
// Allow users to read only their own usage docs
match /usage_docs/{docId} {
allow read: if request.auth != null && request.auth.uid == resource.data.uid;
// Deny all client writes - only functions can write
allow create, update, delete: if false;
}
// Allow users to create their own usage events (functions will handle creation)
match /usage_events/{docId} {
// Deny client writes - only functions can write
allow create, read, update, delete: if false;
}
// Admin-only AI event feed (written by Cloud Functions).
match /admin_ai_events/{docId} {
allow read: if isAdmin();
allow create, update, delete: if false;
}
// Unified admin reports feed (backend exceptions + user feedback/bug reports).
match /admin_reports/{docId} {
allow read, update, delete: if isAdmin();
allow create: if false;
}
}
}