-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
56 lines (47 loc) · 2.12 KB
/
storage.rules
File metadata and controls
56 lines (47 loc) · 2.12 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
45
46
47
48
49
50
51
52
53
54
55
rules_version = '2';
// Firebase Storage Security Rules for TaloFix
// Images are uploaded via Cloud Functions, so no direct create/update rules needed
service firebase.storage {
match /b/{bucket}/o {
// Helper function to check if user is authenticated
function isAuthenticated() {
return request.auth != null;
}
// ========== FAULT REPORT IMAGES ==========
// Path: /faultReports/{reportId}/image_{index}.{ext}
// Upload is handled by Cloud Function (uploadFaultReportImage)
match /faultReports/{reportId}/{imageFile} {
// Only allow reading images (upload via Cloud Function only)
allow read: if isAuthenticated();
// No direct write access - uploads go through Cloud Function
allow write: if false;
}
// ========== USER PROFILE IMAGES (future use) ==========
match /users/{userId}/{imageFile} {
// For now, allow authenticated users to manage their own profile images
allow read: if isAuthenticated();
allow write: if isAuthenticated() && request.auth.uid == userId;
}
// ========== ANNOUNCEMENT ATTACHMENTS ==========
// Path: /announcements/{housingCompanyId}/{attachmentId}/file
// Upload is handled by Cloud Function (uploadAnnouncementAttachment)
// Updates/deletions handled by Cloud Function (updateAnnouncementWithAttachments, deleteAnnouncement)
match /announcements/{housingCompanyId}/{attachmentFolder}/{allFiles=**} {
allow read: if isAuthenticated();
// No direct write access - uploads/deletes go through Cloud Functions
allow write: if false;
}
// ========== LEGACY ANNOUNCEMENT IMAGES ==========
// Path: /announcements/{housingCompanyId}/{fileName}_{timestamp}.{ext}
// Upload is handled by Cloud Function (uploadAnnouncementFile - DEPRECATED)
match /announcements/{housingCompanyId}/{imageFile} {
allow read: if isAuthenticated();
// No direct write access - uploads go through Cloud Function
allow write: if false;
}
// Deny all other paths by default
match /{allPaths=**} {
allow read, write: if false;
}
}
}