This repository has been archived by the owner on Nov 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfirestore.rules
78 lines (65 loc) · 2.59 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
rules_version = '2';
//Firestore database is in complete lockdown
//The data stored in Cloud Firestore (which is FCM token data, user metadata and friend recs)
//is managed entirely by the admin ADK and cloud functions
service cloud.firestore {
match /databases/{database}/documents {
function changedKeysInSet(old, new, set){
return (old == null && new.data.keys().hasOnly(set)) || new.data.diff(old.data).affectedKeys().hasOnly(set)
}
function isLatLngLike(data){
return data is map &&
data.keys().hasOnly(["latitude", "longitude"]) &&
data.latitude is number &&
math.abs(data.latitude) <= 90 &&
data.longitude is float &&
math.abs(data.longitude) <= 180
}
// Users can read their notification data, only cloud functions can write to it
match /fcmData/{userUid} {
allow read: if request.auth != null && request.auth.uid == userUid;
allow write: if false;
}
match /userMetadata/{userUid} {
allow read: if request.auth != null && request.auth.uid == userUid;
allow write: if false;
}
match /publicExtraUserInfo/{userUid} {
allow read: if request.auth != null
allow write: if false;
}
match /friendRecommendations/{docName} {
allow read: if request.auth != null && (request.auth.uid in resource.data.uids || docName.matches(".*"+request.auth.uid+".*"));
allow write: if false;
}
match /userEmailVerifications/{userUid}{
allow read, write: if false
}
match /publicFlareUserMetadataPrivate/{userUid}{
allow read: if false
allow write: if request.auth != null &&
request.auth.uid == userUid &&
changedKeysInSet(resource, request.resource, ["geoHash", "geolocation"].toSet()) &&
request.resource.data.geoHash is string &&
//For some reason the "is latlng" works in the console, but only isLatLngLike works in prod
//TODO: investigate
(request.resource.data.geolocation is latlng || isLatLngLike(request.resource.data.geolocation))
}
match /shortenedPublicFlares/{orgoHash}/public_flares_short/{flareID} {
allow read: if request.auth != null;
allow write: if false;
}
//For collection group queries in the app feed
match /{path=**}/public_flares/{flareID} {
allow read: if request.auth.uid == resource.data.owner.uid;
}
match /publicFlares/{orgoHash}/public_flares/{flareUid} {
allow read: if request.auth != null;
allow write: if false;
match /responders/{responderUid} {
allow read: if request.auth != null;
allow write: if false;
}
}
}
}