-
-
Save adil1214/4f22fc921c384b2694fe063a050e114d to your computer and use it in GitHub Desktop.
Revisions
-
codediodeio revised this gist
Jun 20, 2017 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -78,6 +78,21 @@ } } // Validates timestamp is not a future value { "rules": { "posts": { "$uid": { "timestamp": { ".validate": "newData.val() <= now" } } } } } // Prevents Delete or Update { "rules": { -
codediodeio created this gist
Jun 20, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,125 @@ // No Security { "rules": { ".read": true, ".write": true } } // Full security { "rules": { ".read": false, ".write": false } } // Only authenticated users can access/write data { "rules": { ".read": "auth != null", ".write": "auth != null" } } // Checks auth uid equals database node uid // In other words, the User can only access their own data { "rules": { "posts": { "$uid": { ".read": "$uid === auth.uid", ".write": "$uid === auth.uid" } } } } // Validates user is moderator from different database location { "rules": { "posts": { "$uid": { ".write": "root.child('users').child('moderator').val() === true" } } } } // Validates string datatype and length range { "rules": { "posts": { "$uid": { ".validate": "newData.isString() && newData.val().length > 0 && newData.val().length <= 140" } } } } // Checks presense of child attributes { "rules": { "posts": { "$uid": { ".validate": "newData.hasChildren(['username', 'timestamp'])" } } } } // Prevents Delete or Update { "rules": { "posts": { "$uid": { ".write": "!data.exists()" } } } } // Prevents only Delete { "rules": { "posts": { "$uid": { ".write": "newData.exists()" } } } } // Prevents only Update { "rules": { "posts": { "$uid": { ".write": "!data.exists() || !newData.exists()" } } } } // Prevents Create and Delete { "rules": { "posts": { "$uid": { ".write": "data.exists() && newData.exists()" } } } }