funayaki/acl-manager

This CakePHP plugin is an interface to manage an ACL protected web application.

dev-master 2018-05-25 02:02 UTC

This package is not auto-updated.

Last update: 2024-11-15 20:52:33 UTC


README

Version: 2.3.0 Date: 2013-05-02 Author: Nicolas Rod nico@alaxos.com Website: http://www.alaxos.net/blaxos/pages/view/plugin_acl_2.0 License: http://www.opensource.org/licenses/mit-license.php The MIT License

Requirements

Installation

Install acl and cakephp-js

At first, you need to install acl and cakephp-jp plugins using composer.

The recommended way to install composer packages is:

composer require cakephp/acl
composer require oldskool/cakephp-js:dev-master

Enable acl plugin

In 3.0 you need to enable the plugin your config/bootstrap.php file:

Plugin::load('Acl', ['bootstrap' => true]);

Install acl-manager

[Manual]

  • Download and unzip the repo (see the download button somewhere on this git page)
  • Copy the resulting folder into plugins
  • Rename the folder you just copied to AclManager

[GIT Submodule]

In your app directory type:

git submodule add -b master git://github.com/tsmsogn/acl-manager.git plugins/AclManager
git submodule init
git submodule update

[GIT Clone]

In your plugins directory type:

git clone -b master git://github.com/tsmsogn/acl-manager.git AclManager

Enable plugin

In 3.0 you need to enable the plugin your config/bootstrap.php file:

Plugin::load('AclManager', ['bootstrap' => true, 'routes' => true, 'autoload' => true]);

Acting as a requester

Add $this->addBehavior('Acl.Acl', ['type' => 'requester']); to the initialize function in the files src/Model/Table/RolesTable.php and src/Model/Table/UsersTable.php:

    public function initialize(array $config) {
        parent::initialize($config);

        $this->addBehavior('Acl.Acl', ['type' => 'requester']);
    }

Implement parentNode function in Role entity

Add the following implementation of parentNode to the file src/Model/Entity/Role.php:

    public function parentNode()
    {
        return null;
    }

Implement parentNode function in User entity

Add the following implementation of parentNode to the file src/Model/Entity/User.php:

    public function parentNode()
    {
        if (!$this->id) {
            return null;
        }
        if (isset($this->role_id)) {
            $roleId = $this->role_id;
        } else {
            $Users = TableRegistry::get('Users');
            $user = $Users->find('all', ['fields' => ['role_id']])->where(['id' => $this->id])->first();
            $roleId = $user->role_id;
        }
        if (!$roleId) {
            return null;
        }
        return ['Roles' => ['id' => $roleId]];
    }

Visit acl-manager using browser

Visit /admin/acl_manager/acos/index using browser, you will see anything.