Yii 1.1: rbacmanager

Command-line tool (extends CConsoleCommand) for managing rbac items and assignments.
1 follower

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

Resources

Be the first person to leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: wapmorgan
  • Category: Console
  • Votes: +1
  • Downloaded: 696 times
  • Created on: Dec 5, 2013
  • Last updated: Aug 21, 2014
  • Tags: rbac, cli, console command