Plugin to create Acl for CakePHP 3
Note :
This is a stable plugin for CakePHP 3.0 at this time.This is like Acl on cakephp 2 but has a little different.
you can by use of AclManager create access level for all users.also this is for access level plugin and controller
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require acl-manager/acl
In your config\bootstrap.php
:
Plugin::load('AclManager', ['bootstrap' => false, 'routes' => true]);
Create tables
To create ACL related tables, run the following Migrations command:
bin/cake migrations migrate -p AclManager
You must create values of acos,roles,acos_roles.Well you can use of Shell Acl of plugin. for example :
acos create root plugin
acos create controller Users index
You can see all commands on the help of shell.
If you have prefix you must will enter prefix_action for example : admin_index that is like Cakephp 2
acos create controller Resellers admin_index
you must write this code on method isAuthorized Appcontroller :
public function isAuthorized($user)
{
if (empty($this->request->params['plugin']))
{
$AclManager = $this->loadComponent('AclManager.Check');
if (empty($this->request->params['plugin']))
{
$check_action_curent = $AclManager->Check_request('controller', $this->Auth->
allowedActions);
if (!$check_action_curent)
{
return false;
}else {
return true;
}
}
}
}
you must write this code on method isAuthorized Appcontroller on your plugin :
Also you can create Grade via your controller for example :
$Grade = $this->loadComponent('AclManager.Grade');
$Grade->gradecontroller('user','users','admin_edit'); //** $Grade->gradecontroller(name of roll,controller,action); **//
You must change method beforefilter on other controller for example :
class UsersController extends AppController
{
public function beforeFilter(Event $event = null)
{
$this->Auth->allow(['edit']);
parent::beforeFilter($event);//** we must have parent beforfilter **//
}
}
This code is for dosen't check action edit in plugin Acl.Thats why you allow edit on Auth.This plugin needs develope for will be complete
Enjoy!