-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
68 lines (57 loc) · 1.8 KB
/
storage.rules
File metadata and controls
68 lines (57 loc) · 1.8 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
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Helper function to check if user is admin
function isAdmin() {
return request.auth != null && request.auth.token.admin == true;
}
// Helper function to check file size (5MB max)
function isValidSize() {
return request.resource.size < 5 * 1024 * 1024;
}
// Helper function to check if file is an image
function isImage() {
return request.resource.contentType.matches('image/.*');
}
// Articles images
match /articles/{fileName} {
allow read: if true;
allow write: if isAdmin() && isValidSize() && isImage();
}
// Portfolio images
match /portfolio/{fileName} {
allow read: if true;
allow write: if isAdmin() && isValidSize() && isImage();
}
// Testimonials images
match /testimonials/{fileName} {
allow read: if true;
allow write: if isAdmin() && isValidSize() && isImage();
}
// Carousel images
match /carousels/{fileName} {
allow read: if true;
allow write: if isAdmin() && isValidSize() && isImage();
}
// General uploads
match /uploads/{fileName} {
allow read: if true;
allow write: if isAdmin() && isValidSize() && isImage();
}
// Logos
match /logos/{fileName} {
allow read: if true;
allow write: if isAdmin() && isValidSize() && isImage();
}
// Backups - accessible only by Cloud Functions (Admin SDK)
// Functions use Admin SDK which bypasses security rules
match /backups/{fileName} {
allow read: if isAdmin();
allow write: if false; // Only Cloud Functions can write via Admin SDK
}
// Deny all other access
match /{allPaths=**} {
allow read, write: if false;
}
}
}