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 characters
| // Validates user is moderator from different database location | |
| { | |
| “rules”: { | |
| “posts”: { | |
| “$uid”: { | |
| “.write”: “root.child(‘users’).child(‘moderator’).val() === true” | |
| } | |
| } | |
| } | |
| } |
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 characters
| // These rules grant access to a node matching the authenticated | |
| // user's ID from the Firebase auth token | |
| { | |
| "rules": { | |
| "users": { | |
| "$uid": { | |
| ".read": "$uid === auth.uid", | |
| ".write": "$uid === auth.uid" | |
| } | |
| } |
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 characters
| // Only authenticated users from a particular domain (example.com) can access/write data | |
| { | |
| “rules”: { | |
| “.read”: “auth.token.email.endsWith(‘@example.com’)”, | |
| “.write”: “auth.token.email.endsWith(‘@example.com’)” | |
| } | |
| } |
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 characters
| // Only authenticated users can access/write data | |
| { | |
| “rules”: { | |
| “.read”: “auth != null”, | |
| “.write”: “auth != null” | |
| } | |
| } |
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 characters
| // Full security | |
| { | |
| “rules”: { | |
| “.read”: false, | |
| “.write”: false | |
| } | |
| } |
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 characters
| // No Security | |
| { | |
| “rules”: { | |
| “.read”: true, | |
| “.write”: true | |
| } | |
| } |
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 characters
| // Prevents Delete or Update | |
| { | |
| “rules”: { | |
| “posts”: { | |
| “$uid”: { | |
| “.write”: “!data.exists()” | |
| } | |
| } | |
| } | |
| } |
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 characters
| // Prevents only Delete | |
| { | |
| “rules”: { | |
| “posts”: { | |
| “$uid”: { | |
| “.write”: “newData.exists()” | |
| } | |
| } | |
| } | |
| } |
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 characters
| // Prevents Create and Delete | |
| { | |
| “rules”: { | |
| “posts”: { | |
| “$uid”: { | |
| “.write”: “data.exists() && newData.exists()” | |
| } | |
| } | |
| } | |
| } |
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 characters
| // Allow reads if the group ID in your token matches the file metadata's `owner` property | |
| // Allow writes if the group ID is in the user's custom token | |
| match /files/{groupId}/{fileName} { | |
| allow read: if resource.metadata.owner == request.auth.token.groupId; | |
| allow write: if request.auth.token.groupId == groupId; | |
| } |