-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfirestore.rules
More file actions
88 lines (79 loc) · 3.3 KB
/
Copy pathfirestore.rules
File metadata and controls
88 lines (79 loc) · 3.3 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// GPX uploads — public read; owner can create/update/delete
match /gpx_uploads/{document} {
allow read: if true;
allow create: if request.auth != null
&& request.auth.uid == request.resource.data.userId;
allow update, delete: if request.auth != null
&& request.auth.uid == resource.data.userId;
}
// User bookmarks for preview routes — owner only
match /user_bookmarks/{bookmarkId} {
allow read: if request.auth != null
&& request.auth.uid == resource.data.userId;
allow create: if request.auth != null
&& request.auth.uid == request.resource.data.userId;
allow update, delete: if request.auth != null
&& request.auth.uid == resource.data.userId;
}
// Elevation analysis cache — public read; any authed user can write
match /elevation_analysis_cache/{cacheId} {
allow read: if true;
allow create: if request.auth != null;
allow update, delete: if request.auth != null;
}
// User fuel plans — owner only
match /user_fuel_plans/{planId} {
allow read: if request.auth != null
&& request.auth.uid == resource.data.userId;
allow create: if request.auth != null
&& request.auth.uid == request.resource.data.userId;
allow update: if request.auth != null
&& request.auth.uid == resource.data.userId;
allow delete: if request.auth != null
&& request.auth.uid == resource.data.userId;
}
// User pace plans — owner only
match /user_pace_plans/{planId} {
allow read: if request.auth != null
&& request.auth.uid == resource.data.userId;
allow create: if request.auth != null
&& request.auth.uid == request.resource.data.userId;
allow update: if request.auth != null
&& request.auth.uid == resource.data.userId;
allow delete: if request.auth != null
&& request.auth.uid == resource.data.userId;
}
// User race plans — owner only
match /user_race_plans/{racePlanId} {
allow create: if request.auth != null
&& request.resource.data.userId == request.auth.uid;
allow read, update, delete: if request.auth != null
&& resource.data.userId == request.auth.uid;
}
// User training plans — owner only
match /user_training_plans/{trainingPlanId} {
allow create: if request.auth != null
&& request.resource.data.userId == request.auth.uid;
allow read, update, delete: if request.auth != null
&& resource.data.userId == request.auth.uid;
}
// User training goals — onboarding profile (doc id === userId), owner only.
// Read/delete are keyed on the doc id (not resource.data) so a brand-new
// user can getDoc a not-yet-existing doc without a permission-denied.
// Writes additionally pin the userId field to the requester's uid.
match /user_training_goals/{docId} {
allow read, delete: if request.auth != null
&& request.auth.uid == docId;
allow create, update: if request.auth != null
&& request.auth.uid == docId
&& request.resource.data.userId == request.auth.uid;
}
// Deny everything else by default
match /{document=**} {
allow read, write: if false;
}
}
}