-
Notifications
You must be signed in to change notification settings - Fork 25
/
firestore.rules
110 lines (89 loc) · 3.7 KB
/
firestore.rules
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
service cloud.firestore {
match /databases/{database}/documents {
// Make sure the uid of the requesting user matches name of the user
// document. The wildcard expression {userId} makes the userId variable
// available in rules.
match /users/{userID} {
function isCoach() {
return exists(/databases/$(database)/documents/coaches/$(request.auth.uid)/athletes/$(userID)) && get(/databases/$(database)/documents/coaches/$(request.auth.uid)/athletes/$(userID)).data.accepted == true;
}
allow read: if resource.data.privacy == 'public';
allow read: if isCoach() == true;
allow read, write: if request.auth.uid == userID;
allow create: if request.auth.uid != null;
match /events/{eventID} {
allow read: if resource.data.privacy == 'public';
allow read: if isCoach() == true;
allow read, write: if request.auth.uid == userID;
function eventData() {
return get(/databases/$(database)/documents/users/$(userID)/events/$(eventID)).data
}
match /activities/{activityID} {
allow read: if eventData().privacy == 'public'
allow read: if isCoach() == true;
allow read, write: if request.auth.uid == userID;
match /streams/{streamID} {
allow read: if eventData().privacy == 'public'
allow read: if isCoach() == true;
allow read, write: if request.auth.uid == userID;
}
}
match /metaData/{document=**} {
allow read: if request.auth.uid == userID;
}
}
match /meta/{document=**} {
allow read: if request.auth.uid == userID;
}
}
match /suuntoAppAccessTokens/{userID} {
allow read, write: if request.auth.uid == userID && request.auth.token.firebase.sign_in_provider != 'anonymous';
match /tokens/{document=**} {
allow read, write: if request.auth.uid == userID && request.auth.token.firebase.sign_in_provider != 'anonymous';
}
}
match /COROSAPIAccessTokens/{userID} {
allow read, write: if request.auth.uid == userID && request.auth.token.firebase.sign_in_provider != 'anonymous';
match /tokens/{document=**} {
allow read, write: if request.auth.uid == userID && request.auth.token.firebase.sign_in_provider != 'anonymous';
}
}
match /garminHealthAPITokens/{userID} {
allow read, write: if request.auth.uid == userID && request.auth.token.firebase.sign_in_provider != 'anonymous';
}
match /garminHealthAPIActivityQueue/{userID} {
allow read, write: if false;
}
match /COROSAPIWorkoutQueue/{userID} {
allow read, write: if false;
}
match /COROSAPIHistoryImportWorkoutQueue/{userID} {
allow read, write: if false;
}
match /suuntoAppWorkoutQueue/{userID} {
allow read, write: if false;
}
match /suuntoAppHistoryImportActivityQueue/{userID} {
allow read, write: if false;
}
// @todo perhaps restrict to user ID
match /userAccountPrivileges/{document=**} {
allow write: if false;
allow read: if true;
}
match /coaches/{userID} {
allow read, write: if request.auth.uid == userID && request.auth.token.firebase.sign_in_provider != 'anonymous';
match /athletes/{athleteUserID} {
allow read,delete: if request.auth.uid == userID && request.auth.token.firebase.sign_in_provider != 'anonymous';
allow read, write: if request.auth.uid == athleteUserID && request.auth.token.firebase.sign_in_provider != 'anonymous';
}
}
}
}
service firebase.storage {
match /b/{bucket}/o {
match /assets/{allPaths=**} {
allow read;
}
}
}