fusible / authrole
Integrate Aura\Auth and Zend\Permissions\Acl
dev-develop
2016-05-21 04:42 UTC
Requires
- aura/auth: ^2.0
- zendframework/zend-permissions-acl: ^2.6
This package is auto-updated.
Last update: 2024-10-29 04:58:49 UTC
README
Integrate Aura\Auth and Zend\Permissions\Acl
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';