gintonicweb/permissions

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.

Permissions plugin for CakePHP

Installs: 453

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:cakephp-plugin

dev-master 2016-05-07 08:09 UTC

This package is not auto-updated.

Last update: 2019-02-20 18:44:58 UTC


README

Build Status codecov.io

Permissions plugin for CakePHP

Warning

Do not use, very early stage

Installation

composer require gintonicweb/permissions

In your app's config/bootstrap.php add:

Plugin::load('Permissions');

Usage

In your Auth setup, use ConfigAuthorize for authorization.

public $components = array(
    'Auth' => [
        'authorize' => ['Permissions.Config'],
    ]
);

In your controllers you can now use an array like this to grant permissions to specific actions for specific roles

// Add Role at the top of your controller like this
// use Permissions\Model\Entity\Role;

public $_permissions = [
    Role::ADMIN => '*',
    Role::USER => ['index', 'view'],
];

You can also add the Roles Listener in bootstrap.php if you want to have access to the users role from the Auth component.

// in config/bootstrap.php
use Permissions\Listener\RoleListener;
EventManager::instance()->attach(new RoleListener());

which makes it possible now to do things like

$role = $this->Auth->user('role');
$roleName = Role::types($role);