-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
56 lines (45 loc) · 1.78 KB
/
Copy pathstorage.rules
File metadata and controls
56 lines (45 loc) · 1.78 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
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// ─────────────────────────────────────────────
// HELPER FUNCTIONS
// ─────────────────────────────────────────────
function isAuthenticated() {
return request.auth != null;
}
function isAdmin() {
return isAuthenticated() &&
firestore.get(/databases/(default)/documents/users/$(request.auth.uid)).data.role == 'admin';
}
// ─────────────────────────────────────────────
// FOLDER RULES
// ─────────────────────────────────────────────
// Products & Collections: Publicly readable, Admin writeable
match /products/{allPaths=**} {
allow read: if true;
allow write: if isAdmin();
}
match /collections/{allPaths=**} {
allow read: if true;
allow write: if isAdmin();
}
match /general/{allPaths=**} {
allow read: if true;
allow write: if isAdmin();
}
match /blog/{allPaths=**} {
allow read: if true;
allow write: if isAdmin();
}
// Digital Assets: Restricted to Admin write and read.
// Client access is mediated via the secure Next.js /api/downloads endpoint
// which verifies ownership in Firestore before streaming the file.
match /digital-assets/{assetId} {
allow read, write: if isAdmin();
}
// Default deny
match /{allPaths=**} {
allow read, write: if false;
}
}
}