-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
76 lines (68 loc) · 2.67 KB
/
Copy pathstorage.rules
File metadata and controls
76 lines (68 loc) · 2.67 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Listings images - authenticated users can upload to their own folder
match /listings/{listingType}/{userId}/{allPaths=**} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == userId;
}
// User profile images - only authenticated users can view
match /users/{userId}/{allPaths=**} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.auth.uid == userId;
}
// Vehicle images
match /vehicles/{userId}/{allPaths=**} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == userId;
}
// Public profile avatar photos
match /profile-photos/{userId}/{allPaths=**} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == userId;
}
// Public profile gallery photos (truck/cargo)
match /profile-gallery/{userId}/{allPaths=**} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == userId;
}
// Payment screenshots - users can upload to their own folder
// Only images under 5MB allowed
match /payments/{userId}/{allPaths=**} {
// Users can read their own, admins (with custom claim) can read all for review
allow read: if request.auth != null && (
request.auth.uid == userId ||
request.auth.token.admin == true
);
// Users can only upload images under 5MB
allow write: if request.auth != null
&& request.auth.uid == userId
&& request.resource.size < 5 * 1024 * 1024
&& (request.resource.contentType == 'image/jpeg'
|| request.resource.contentType == 'image/png'
|| request.resource.contentType == 'image/webp');
}
// Trucker compliance documents (driver license + LTO copy)
match /trucker-docs/{userId}/{allPaths=**} {
allow read: if request.auth != null && (
request.auth.uid == userId ||
request.auth.token.admin == true
);
allow write: if request.auth != null
&& request.auth.uid == userId
&& request.resource.size < 5 * 1024 * 1024
&& (request.resource.contentType == 'image/jpeg'
|| request.resource.contentType == 'image/png'
|| request.resource.contentType == 'image/webp');
}
// Static assets folder (GCash QR code, etc.) - public read
match /assets/{allPaths=**} {
allow read: if true;
allow write: if false; // Only admin uploads via Firebase Console
}
// Default deny all other paths
match /{allPaths=**} {
allow read, write: if false;
}
}
}