fuzzyworld

north-star / files / config / firebase / database.rules.json

database.rules.json

1.4 KB · history · blame

1{
2 "rules": {
3 ".read": false,
4 ".write": false,
5 "rooms": {
6 "$roomId": {
7 ".read": "auth != null && $roomId.matches(/^[a-z0-9]{8}$/)",
8 "friends": {
9 "$uid": {
10 ".write": "auth != null && (auth.uid === $uid || (!newData.exists() && data.child('lastSeen').isNumber() && data.child('lastSeen').val() < now - 2592000000))",
11 ".validate": "!newData.exists() || (newData.hasChildren(['encryptedState']) && newData.child('encryptedState').isString() && newData.child('encryptedState').val().length > 0 && !newData.child('id').exists() && !newData.child('name').exists() && !newData.child('color').exists() && !newData.child('position').exists() && !newData.child('timestamp').exists()) || (newData.hasChildren(['id','name','color','position','timestamp']) && newData.child('id').isString() && newData.child('id').val() === auth.uid && newData.child('name').isString() && newData.child('name').val().length > 0 && newData.child('name').val().length <= 32 && newData.child('color').isString() && newData.child('color').val().matches(/^#[0-9a-fA-F]{6}$/) && newData.child('position').hasChildren(['lat','lon']) && newData.child('position/lat').isNumber() && newData.child('position/lon').isNumber() && newData.child('timestamp').isNumber())"
12 }
13 }
14 }
15 }
16 }
17}