-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
32 lines (27 loc) · 1012 Bytes
/
Copy pathstorage.rules
File metadata and controls
32 lines (27 loc) · 1012 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
31
32
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 uploads folder - users can only access their own files
match /users/{userId}/{allPaths=**} {
allow read: if isAuthenticated() && request.auth.uid == userId;
allow write: if isAuthenticated() &&
request.auth.uid == userId &&
request.resource.size < 5 * 1024 * 1024 && // Max 5MB
request.resource.contentType.matches('image/.*'); // Only images
}
// Food images - authenticated users can read, only app can write
match /food_images/{imageId} {
allow read: if isAuthenticated();
allow write: if false; // Only backend can write
}
// Public assets - anyone can read
match /public/{allPaths=**} {
allow read: if true;
allow write: if false;
}
}
}