-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirebaseDatabaseRules.json
More file actions
51 lines (45 loc) · 2.23 KB
/
firebaseDatabaseRules.json
File metadata and controls
51 lines (45 loc) · 2.23 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
// Firebase configuration saving this file for documentation/code history
//These configuration settings should match the settings actually on firebase, please keep them in sync
//Pasting these rules into firebase will remove the comments, no need to manually remove them
//Templates to reduce typing, can use for copy pasta
// ".read": "auth != null",
// ".write": "auth != null"
{
"rules": {
//Meetup access, everyone can read a meetup
//Anyone can create a meetup
//You can only write to a meetup if you are the creator
//Validation rules
//Required fields: creatorId, date, description, imageUrl, location, title
//TODO: Figure out how to properly setup/test api end point security as you set these up as this looks as it is easy to make a
//mistake and have a security hole
"meetups": {
".read": true,
".write": "auth != null",
"$meetup_id": {
".validate": "newData.hasChildren(['creatorId', 'title', 'date','location', 'description'])",
"creatorId": {
".validate": "(newData.val() === auth.uid && !data.exists()) ||(data.val() === auth.uid && data.exists())"
},
"title": { ".validate": "newData.isString()"},
"date": { ".validate": "newData.isString() && newData.val().matches(/(\\d{4})-(\\d{2})-(\\d{2})T((\\d{2}):(\\d{2}):(\\d{2})\\.(\\d{3}))Z/)"},
"location": { ".validate": "newData.isString()"},
"description": { ".validate": "newData.isString()"},
"imageUrl": { ".validate": "newData.isString()"},
"$other": { ".validate": false }
}
},
//Everyone can view your profile/meetups you signed up for
//Only you can write to your own profile/register for meetups
"users": {
".read": true,
"$user_id": {
".write": "auth.uid === $user_id",
"registrations": {
"$registration_id": {".validate": "root.child('meetups').hasChild(newData.val()) && newData.isString()" }
},
"$other": { ".validate": false }
}
}
}
}