forked from stellar-nexus-experience/demo-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
59 lines (38 loc) · 1.69 KB
/
firestore.rules
File metadata and controls
59 lines (38 loc) · 1.69 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
41
42
43
44
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Users can read and write their own account documents
match /accounts/{userId} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.auth.uid == userId;
}
// Users can read and write their own points transactions
match /pointsTransactions/{transactionId} {
allow read, write: if request.auth != null && resource.data.userId == request.auth.uid;
}
// Allow reading demo progress for authenticated users
match /demoProgress/{progressId} {
allow read, write: if request.auth != null && resource.data.userId == request.auth.uid;
}
// Mandatory feedback collection - users can submit feedback, admins can read all
match /mandatory_feedback/{feedbackId} {
allow create: if request.auth != null &&
request.auth.uid == request.resource.data.userId &&
request.resource.data.keys().hasAll(['userId', 'demoId', 'demoName', 'rating', 'feedback', 'difficulty', 'wouldRecommend', 'completionTime', 'timestamp']);
allow read: if request.auth != null &&
(request.auth.uid == resource.data.userId ||
request.auth.token.admin == true);
allow update, delete: if false; // Feedback is immutable once submitted
}
// Leaderboard - public read, no write
match /leaderboard/{entryId} {
allow read: if true;
allow write: if false;
}
// Analytics - read for authenticated users
match /analytics/{document=**} {
allow read: if request.auth != null;
allow write: if false; // Only server-side writes allowed
}
}
}