Open syu93 opened 8 years ago
How to structure data https://firebase.google.com/docs/database/web/structure-data
How to secure data https://firebase.google.com/docs/storage/security/start
@berrabahs
I've worked a way to create a role system to protect data.
Here is a great example :
https://github.com/firebase/firechat/blob/master/rules.json
here is some samle i've created to show you the way
// Rules
{
"rules": {
// Read is forbiden for all by default
".read": false,
".write": false,
"users": {
"$users": {
"basicInfo": {
// To read besic info the user must be authenticated
".read": "(auth != null)",
// The write here the user must be the user itself or either a moderator or an administrator
".write": "(auth.uid == $users || root.child('moderators').hasChild(auth.uid) || root.child('adminisrators').hasChild(auth.uid))"
},
"advancedInfo": {
// The write here the user must be the user itself or either a moderator or an administrator
".read": "(auth.uid == $users || root.child('moderators').hasChild(auth.uid) || root.child('adminisrators').hasChild(auth.uid))",
".write": "(auth.uid == $users || root.child('moderators').hasChild(auth.uid) || root.child('adminisrators').hasChild(auth.uid))"
}
}
}
}
}
{
"administrators" : {
"a094c6773-08a1-493b-a018-fbeb386721bf" : "99"
},
"moderators" : {
"a094c6773-08a1-493b-a018-fbeb386721bf" : "10"
},
"users" : {
"094c6773-08a1-493b-a018-fbeb386721bf" : {
"advancedInfo" : {
"email" : "plop@plop.com"
},
"basicInfo" : {
"name" : "Plop"
}
}
}
}
Design the database architecture.
Inspire from wordpress without all the complexity:
https://codex.wordpress.org/images/2/25/WP4.4.2-ERD.png
Prefixed with : ar_