-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
48 lines (40 loc) · 1.54 KB
/
storage.rules
File metadata and controls
48 lines (40 loc) · 1.54 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
rules_version = '2';
// Firebase Storage Security Rules
service firebase.storage {
match /b/{bucket}/o {
// Helper functions
function isSignedIn() {
return request.auth != null;
}
function isAdmin() {
return isSignedIn() && request.auth.token.email == 'hariprakashpc@gmail.com';
}
// Product images - public read, auth write, supports nested paths (e.g., products/{productId}/image.jpg)
match /products/{productId}/{allPaths=**} {
allow read: if true; // Public read access
allow write: if isSignedIn(); // Any authenticated user can upload
allow delete: if isAdmin(); // Only admin can delete
}
// Profile pictures - public read, user-only write
match /profile_pictures/{userId}/{fileName} {
allow read: if true; // Public read so images can be displayed
allow write: if isSignedIn() && request.auth.uid == userId;
allow delete: if isSignedIn() && request.auth.uid == userId;
}
// Legacy paths for backward compatibility
match /profilePictures/{userId} {
allow read: if true;
allow write: if isSignedIn() && request.auth.uid == userId;
allow delete: if isSignedIn() && request.auth.uid == userId;
}
match /profiles/{userId}/{imageId} {
allow read: if true;
allow write: if isSignedIn() && request.auth.uid == userId;
allow delete: if isSignedIn() && request.auth.uid == userId;
}
// Default: deny all other access
match /{allPaths=**} {
allow read, write: if false;
}
}
}