Integrate Aura\Auth and Zend\Permissions\Acl
composer require fusible/authrole
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';