-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
30 lines (25 loc) · 850 Bytes
/
storage.rules
File metadata and controls
30 lines (25 loc) · 850 Bytes
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
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Helper function to check if user is authenticated
function isAuthenticated() {
return request.auth != null;
}
// User profile images - users can only access their own folder
match /users/{userId}/{allPaths=**} {
allow read: if isAuthenticated();
allow write: if isAuthenticated() && request.auth.uid == userId;
}
// Public uploads folder (authenticated users only)
match /uploads/{allPaths=**} {
allow read: if true;
allow write: if isAuthenticated()
&& request.resource.size < 5 * 1024 * 1024 // Max 5MB
&& request.resource.contentType.matches('image/.*');
}
// Default: Deny all access
match /{allPaths=**} {
allow read, write: if false;
}
}
}