2017 © Pedro Peláez
 

yii2-extension yii2-rbac-plus

Database role base access control manager for yii2

image

jeffwalsh/yii2-rbac-plus

Database role base access control manager for yii2

  • Wednesday, December 6, 2017
  • by jeffwalsh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 115 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 47 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

yii2-rbac-plus

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads, (*1)

Database role base access control manager for yii2, (*2)

Features

  • CRUD operations for roles, permissions and rules
  • Allows to assign multiple roles to user
  • Nice views to intergrate right away
  • Integrated with Yii2-user-plus - flexible user management module

Yii2 RBAC manager, (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist johnitvn/yii2-rbac-plus "*"

or add, (*6)

"johnitvn/yii2-rbac-plus": "*"

to the require section of your composer.json file., (*7)

Usage

  1. Let 's add into modules config in your main config file
'components' => [
    'authManager' => [
        'class' => 'yii\rbac\DbManager',
    ],
],
'modules' => [
    'rbac' =>  [
        'class' => 'johnitvn\rbacplus\Module'
    ]       
]

Next, update the database schema, (*8)

$ php yii migrate/up --migrationPath=@yii/rbac/migrations

Ok. That's done. Avaiable route now:, (*9)

  • /rbac/rule
  • /rbac/permission
  • /rbac/role
  • /rbac/assignment
  1. The module configuration avaible:
'modules' => [
    'rbac' =>  [
        'class' => 'johnitvn\rbacplus\Module',
        'userModelClassName'=>null,
        'userModelIdField'=>'id',
        'userModelLoginField'=>'username',
        'userModelLoginFieldLabel'=>null,
        'userModelExtraDataColumls'=>null,
        'beforeCreateController'=>null,
        'beforeAction'=>null
    ]       
]
  • userModelClassName: The user model class.
    If you not set or set null, RBAC Plus will be get from Yii::$app->getUser()->identityClass
  • userModelIdField: The user model id field.
    Default id field is 'id', you must set this config if primary key of user table in database is not 'id'
  • userModelLoginField The user model login field.
    Default login field is 'username'. Maybe you use email field or something other for login. So you must change this config
  • userModelLoginFieldLabel The user model login field label.
    If you set null the label will get from $userModelClass->attributeLabels()[$userModelLoginField]
  • userModelExtraDataColumls The extra data columns you want to show in user assign views.
    The default in assignment data gridview just display id and login column data. if you want to add created_at column you can add
'userModelExtraDataColumls'=>[
    [
        'attributes'=>'created_at',
        'value'=>function($model){
            return date('m/d/Y', $model->created_at);
        }
    ]
]
  • beforeCreateController The callable before create all controller of Rbac Plus module. The default it is null. You need config this when you want to restrict access to Rbac Plus module.
    Example:
'beforeCreateController'=>function($route){
    /**
    *@var string $route The route consisting of module, controller and action IDs.
    */    
}
  • beforeActionThe callable before action of all controller in Rbac Plus module.
    The default it is null. You need config this when you want to restrict access to any action in some controller of Rbac Plus module
    Example:
'beforeAction'=>function($action){
    /**
    *@var yii\base\Action $action the action to be executed.
    */    
}

The Versions

06/12 2017

dev-master

9999999-dev

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

06/12 2017

1.0.9

1.0.9.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

06/12 2017

1.0.8

1.0.8.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

18/10 2017

1.0.7

1.0.7.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

16/02 2016

1.0.6

1.0.6.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

08/09 2015

1.0.5

1.0.5.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

07/09 2015

1.0.4

1.0.4.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

25/08 2015

1.0.3

1.0.3.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

13/08 2015

1.0.2

1.0.2.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

06/08 2015

1.0.1

1.0.1.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires

 

23/07 2015

1.0.0

1.0.0.0

Database role base access control manager for yii2

  Sources   Download

Apache-2.0

The Requires