fusible/authrole

Integrate Aura\Auth and Zend\Permissions\Acl

dev-develop 2016-05-21 04:42 UTC

This package is auto-updated.

Last update: 2024-03-29 03:38:01 UTC


README

Integrate Aura\Auth and Zend\Permissions\Acl

Latest version Build Status Coverage Status Quality Score

Installation

composer require fusible/authrole

Usage

Replace Aura\Auth\AuthFactory with Fusible\AuthRole\AuthFactory. The resulting Auth object will implement Zend\Permissions\Acl\Role\RoleInterface

If $auth->isValid() is false, $auth->getRoleId() will return Auth::GUEST ("guest").

If $auth->isValid() is true, getRoleId will look for a key role in the result of $auth->getUserData and return that, or return Auth::MEMBER ("member") if it is not set.

use Fusible\AuthRole\AuthFactory;
use Fusible\AuthRole\Auth;
use Zend\Permissions\Acl\Acl;

$factory = new AuthFactory($_COOKIE);
$auth = $factory->newInstance();
$acl = new Acl();

$acl->addRole(Auth::GUEST)
    ->addRole(Auth::MEMBER);

$acl->addResource('someResource');

$acl->deny('guest', 'someResource');
$acl->allow('member', 'someResource');


$resume = $factory->newResumeService();
$resume->resume($auth);

echo $acl->isAllowed($auth, 'someResource') ? 'allowed' : 'denied';