-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.rules.js
63 lines (52 loc) · 1.53 KB
/
storage.rules.js
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
// Artist-Tekuma Storage Rules:
// ===========================
// Goals:
// - only allow users to store data in folder with their UID
// - Set maximum size for any uploaded file to xMB
// - File type restrictions?
//
//
//
// service firebase.storage {
// match /b/art-uploads/o { //match our storage bucket URL
// match /portal/{thisUID}/{dir}/{filename} {
// allow read, write : if (request.auth.uid == thisUID || isAdmin() )
// }
// }
// }
// checks if is from an admin user.
function isAdmin() {
return (request.auth.uid == 'cacxZwqfArVzrUXD5tn1t24OlJJ2' ||
request.auth.uid == 'JZ2H4oD34vaTwHanNVPxKKHy3ZQ2' ||
request.auth.uid == 'naomiUID' ||
request.auth.uid == 'scottUID' ||
request.auth.uid == 'marwanUID' );
}
function hasPermission(uid) {
return (request.auth.uid == uid)
}
function uploadIsLegal(maxSizeInMB) {
return (request.resource.size <= maxSizeInMB *1024*1024
&& request.resource.contentType.matches('image/.*'))
}
// 20MB set as max file upload size.
function isValidUpload(uid) {
return ( (hasPermission(uid) || isAdmin()) && uploadIsLegal(20) )
}
// service firebase.storage {
// match /b/art-uploads/o {
// match /portal/{thisUID}/{dir}/{filename} {
// allow read, write: if isValidUpload(thisUID);
// }
// }
// }
//
//
// NOTE: This allows all writing to bucket. Dangerous.
service firebase.storage {
match /b/art-uploads/o {
match /{allPaths=**} {
allow read, write: if true;
}
}
}