-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
39 lines (32 loc) · 1.22 KB
/
storage.rules
File metadata and controls
39 lines (32 loc) · 1.22 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
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Helper functions
function isAuthenticated() {
return request.auth != null;
}
function isManagerOrAdmin() {
return isAuthenticated() && firestore.get(/databases/(default)/documents/users/$(request.auth.uid)).data.role in ['MANAGER', 'ADMINISTRATOR'];
}
// Optimized Big Data Structure (Hive Partitioning)
// Structure: proofs/year=YYYY/month=MM/day=DD/filename.png
// Allow listing/reading/creation of all proofs (recursive)
// Simplified rule to allow arbitrary nesting depth which occurs in RouteEditor.tsx
// Structure: proofs/city={cityName}/year={YYYY}/month={MM}/day={DD}/...
match /proofs/{allPaths=**} {
allow read: if isManagerOrAdmin();
allow create: if isAuthenticated()
&& request.resource.size < 5 * 1024 * 1024 // Max 5MB
&& request.resource.contentType.matches('image/.*');
allow update, delete: if isManagerOrAdmin();
}
// Backups (Admin Only)
match /backups/{allPaths=**} {
allow read, write: if isManagerOrAdmin();
}
// Default deny
match /{allPaths=**} {
allow read, write: if false;
}
}
}