-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
54 lines (45 loc) · 1.65 KB
/
firestore.rules
File metadata and controls
54 lines (45 loc) · 1.65 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// ── Production rules (Firebase Auth required) ─────────────
function isAuthenticated() {
return request.auth != null;
}
function isOwner(userId) {
return isAuthenticated() && request.auth.uid == userId;
}
function validFaceWrite(userId) {
return request.resource.data.person_name is string
&& request.resource.data.relationship is string
&& request.resource.data.photo_index is int
&& request.resource.data.registered_by is string
&& request.resource.data.registered_by == userId
&& (
!('reference_photo_base64' in request.resource.data)
|| (
request.resource.data.consent_confirmed == true
&& request.resource.data.reference_photo_base64 is string
&& request.resource.data.reference_photo_base64.size() <= 350000
)
);
}
match /user_profiles/{userId} {
allow read, write: if isOwner(userId);
match /face_library/{faceId} {
allow read: if isOwner(userId);
allow create, update: if isOwner(userId) && validFaceWrite(userId);
allow delete: if isOwner(userId);
}
match /sessions_meta/{sessionId} {
allow read, write: if isOwner(userId);
}
match /memories/{memoryId} {
allow read, write: if isOwner(userId);
}
}
// ── Deny all other access by default ───────────────────────────
match /{document=**} {
allow read, write: if false;
}
}
}