2017 © Pedro Peláez
 

yii2-extension yii2-rbac-collector

Using extension you can organize your RBAC configuration in separate files in application modules.

image

romi45/yii2-rbac-collector

Using extension you can organize your RBAC configuration in separate files in application modules.

  • Tuesday, April 3, 2018
  • by romi45
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,398 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 51 % Grown

The README.md

Yii 2 RBAC configuration stored in separate modules

This extension provides layer between Yii 2 AuthManager and access configuration that can be stored in separate config classes in application modules., (*1)

It is useful for large projects where you have truckload of access rules, roles and other stuff., (*2)

When you organize your RBAC code in modules - you can easy manage it., (*3)

It is only console application component - you don't have to change something in your web application - just use Yii::$app->authManager as you used it before., (*4)

Installation

Install this extension through composer., (*5)

Either run, (*6)

$ composer require romi45/yii2-rbac-collector:~1.0

or add, (*7)

"romi45/yii2-rbac-collector": "~1.0"

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

Configuring

Add rbacc module into your modules section in console application config., (*9)

'modules' => [
    ...
    'rbacc' => [
        'class' => 'rbacc\Module',
        'collection' => [
            // Here is a list of your RBAC config classes. Example you can get in /example directory
            'app\modules\user\rbac\Config',
            'app\modules\blog\rbac\Config',
            'app\modules\hobby\rbac\YouCanNameItAsYouWant',
        ]
    ],
    ...
]

Here is an example of config class. array keys - auth item name value - auth item data, (*10)

if value is not array - collector recognize it as Permission. if value is array - you have to specify type of Item, (*11)


namespace rbacc\example; use rbacc\components\ConfigBase; use rbacc\example\rules\UpdateOwnDataRule; use yii\rbac\Item; /** * Class Config * * Example RBAC configuration class * * @package user\rbac */ class Config extends ConfigBase { /** * Gets config data as array * * @return array */ public function getData() { return [ 'user___user__view_profile' => 'View user profile', 'user___user__view_own_profile' => [ 'type' => Item::TYPE_PERMISSION, 'description' => 'View user own profile', 'rule' => new UpdateOwnDataRule(), 'children' => ['user___user__view_profile'] ], 'user' => [ 'type' => Item::TYPE_ROLE, 'description' => 'User', 'children' => ['user___user__view_own_profile'], ], 'admin' => [ 'type' => Item::TYPE_ROLE, 'description' => 'Admin', 'children' => ['user___user__view_profile'] ], 'owner' => [ 'type' => Item::TYPE_ROLE, 'description' => 'Application owner', 'children' => ['admin'], ] ]; } }

For updating RBAC configuration after some changes jus run following command:, (*12)

$ yii rbacc/update

Collector will read your config classes and update RBAC data using your current AuthManager - PhpManager or DbManager, (*13)

License

The MIT License (MIT). Please see License File for more information., (*14)

The Versions

03/04 2018

dev-master

9999999-dev

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

03/04 2018

1.0.8

1.0.8.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

02/04 2018

1.0.7

1.0.7.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

17/08 2017

1.0.6

1.0.6.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

22/06 2016

1.0.5

1.0.5.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

21/04 2016

1.0.4

1.0.4.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

21/04 2016

1.0.3

1.0.3.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

12/04 2016

1.0.2

1.0.2.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

08/04 2016

1.0.1

1.0.1.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45

07/04 2016

1.0.0

1.0.0.0

Using extension you can organize your RBAC configuration in separate files in application modules.

  Sources   Download

MIT

The Requires

 

by Roman Agilov

yii2 rbac romi45