Skip to content

Instantly share code, notes, and snippets.

@anhdiepmmk
Last active May 21, 2022 06:09
Show Gist options
  • Save anhdiepmmk/0c60648a8998d2caace0417aa05bce65 to your computer and use it in GitHub Desktop.
Save anhdiepmmk/0c60648a8998d2caace0417aa05bce65 to your computer and use it in GitHub Desktop.
rbac model
verb:
- create
- update
- delete
- read
...
subject:
- user
- listing
- booking
...
scope:
- all
- own
- () => ()
verb_subject (permission):
- create - user
- update - user
- delete - user
- read - user
- create - listing
- update - listing
- delete - listing
- read - listing
...
role
- superadmin
- admin
- user
- guest
...
role_permission (role_verb_subject)
- admin - create - user
- admin - update - user
- admin - read - user
- admin - create - listing
- admin - update - listing
- admin - read - listing
- user - read - user
- user - update - user
- user - read - listing
- user - create - listing
- user - update - listing
- guest - read - listing
...
user
- alice
- bob
- diep
user_role
- bob - superadmin
- alice - admin
- alice - user
- diep - guest
// polulated
{
name: alice,
roles: [
{
name: admin,
permissions: [
{
verb: create,
subject: user
},
{
verb: update,
subject: user
},
{
verb: read,
subject: user
},
{
verb: create,
subject: listing
},
{
verb: update,
subject: listing
},
{
verb: read,
subject: listing
}
]
},
{
name: user,
permissions: [
{
verb: read,
subject: user
},
{
verb: update,
subject: user
},
{
verb: read,
subject: listing
},
{
verb: create,
subject: listing
},
{
verb: update,
subject: listing
},
]
}
]
}
// translated
["create:user", "update:user", "read:user", "create:listing", "update:listing", "read:listing"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment