RbacManager is a command-line tool (extends CConsoleCommand) for managing rbac items and assignments.
It can be installed with composer: wapmorgan/rbacmanager.
Installation ¶
Put this in your config/console.php
'commandMap' => array(
'rbac' => array(
'class' => 'ext.RbacManager.RbacCommand',
'modelClass' => '\Users\models\User',
),
),
modelClass either can be class name under namespace like \Users\models\User
or alias like application.modules.users.models.User
.
Usage ¶
Available actions:
Creating auth item ~~~ $ ../yiic rbac create role admin Created role admin $ ../yiic rbac create task editPost Created task editPost $ ../yiic rbac create operation operationOne Created operation operationOne ~~~
Deleting auth item ~~~ $ ../yiic rbac delete admin Removed admin ~~~
Granting a user ~~~ $ ../yiic rbac grantUser --username=wapmorgan admin editPost operationOne wapmorgan += admin wapmorgan += editPost wapmorgan += operationOne ~~~ or ~~~ $ ../yiic rbac grantUser --id=1 admin editPost operationOne wapmorgan += admin wapmorgan += editPost wapmorgan += operationOne ~~~
Taking grants back ~~~ $ ../yiic rbac clearUser --username=wapmorgan admin editPost Revoked admin Revoked editPost ~~~ or ~~~ $ ../yiic rbac clearUser --id=1 admin editPost Revoked admin Revoked editPost ~~~ Use '--all' option to delete all grants ~~~ $ ../yiic rbac clearUser --id=1 --all Revoked admin Revoked editPost Revoked operationOne ~~~
Taking a look at user's grants ~~~ $ ../yiic rbac describeUser --username=wapmorgan admin editPost operationOne ~~~
Showing all roles and users that have these roles ~~~ $ ../yiic rbac [admin] wapmorgan ~~~
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.