2017 © Pedro Peláez
 

yii2-extension easyii-rbac-module

Role Base Access for EasyiiCMS

image

developeruz/easyii-rbac-module

Role Base Access for EasyiiCMS

  • Friday, February 3, 2017
  • by DeveloperUz
  • Repository
  • 2 Watchers
  • 3 Stars
  • 88 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Role Base Access for EasyiiCMS

This module allows add Rbac module to Easy yii2 cms, (*1)

Installation guide

Please, install User module for EasyiiCMS by following these instructions before going further, (*2)

$ php composer.phar require developeruz/easyii-rbac-module "dev-master"

Replace last line in app/config/web.php, (*3)

$config = array_merge_recursive($config,
    require($webroot . '/vendor/developeruz/easyii-user-module/config/user_module_config.php'),
    require($webroot . '/vendor/noumo/easyii/config/easyii.php'));
$config['components']['user'] = [ 'identityClass' => 'developeruz\easyii_user\models\User' ];
return $config;

with, (*4)

$config = array_merge_recursive($config,
    require($webroot . '/vendor/developeruz/easyii-user-module/config/user_module_config.php'),
    require($webroot . '/vendor/developeruz/easyii-rbac-module/config/rbac_module_config.php'),
    require($webroot . '/vendor/noumo/easyii/config/easyii.php'));
$config['components']['user'] = [ 'identityClass' => 'developeruz\easyii_rbac\models\User' ];
return $config;

Add authManager to components in app/config/console.php and app/config/web.php, (*5)

'components' => [
      ...
      'authManager' => [
        'class' => 'yii\rbac\DbManager',
      ],
]

Run authManager migrations, (*6)

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

Run migrations, (*7)

php yii migrate --migrationPath=@vendor/developeruz/easyii-rbac-module/migrations

Open User CRUD page (url admin/user), you will see change user role button in action buttons column. Click on it and assign Adminrole to admin user., (*8)

Add behaviour in app/config/web.php, (*9)

'components' => [
...
],
'modules' => [
... 
],
'as AccessBehavior' => [
        'class' => \developeruz\db_rbac\behaviors\AccessBehavior::className(),
        'login_url' => '/admin/sign/in',
        'rules' => [
            'user/security' => [['actions' => ['login'], 'allow' => true ],
                                ['actions' => ['logout'], 'roles' => ['@'], 'allow' => true ]],
            'user/settings' => [['roles' => ['@'], 'allow' => true ]],
            'admin/sign' => [['actions' => ['in'], 'allow' => true],
                             ['actions' => ['out'], 'roles' => ['@'], 'allow' => true ]],

            'site' =>[[ 'allow' => true]],
            'articles' =>[[ 'allow' => true]],
            'gallery' =>[[ 'allow' => true]],
            'news' =>[[ 'allow' => true]],
        ],
]

Add all public controllers in rules., (*10)

If the user doesn't have access to admin panel, admin Toolbar will be hidden on front pages via adding css display:none. It is compelled workaround because Easy yii2 cms doesn't allow to overwrite this part. I will create PR and change the behavior in this module as soon as it would be possible., (*11)

License

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

The Versions

03/02 2017

dev-master

9999999-dev

Role Base Access for EasyiiCMS

  Sources   Download

MIT

The Requires

 

module cms yii easyiicms