Acl allow role access on all resources not honoured if added after resources #3934

Closed
CrispCreations opened this Issue Mar 2, 2013 · 1 comment

3 participants

@CrispCreations

Seems that if resources are added before a call is made to allow a role access to all resources, the rule isn't applied.

//Test case 1: Resource added before allow rule

$acl = new \Zend\Permissions\Acl\Acl;
$acl->addRole('admin');
$acl->addResource('foo'); // resource before rule
$acl->allow('admin'); // allow admin access to all resources

// this fails
echo 'Expected Allowed: Actual ', $acl->isAllowed('admin') ? 'Allowed' : 'Denied';
echo 'Expected Allowed: Actual ', $acl->isAllowed('admin', null, 'view') ? 'Allowed' : 'Denied';

//Test case 2: Resource added after allow rule

$acl = new \Zend\Permissions\Acl\Acl;
$acl->addRole('admin');
$acl->allow('admin'); // allow admin access to all resources
$acl->addResource('foo'); // resource after rule

// this works as expected
echo 'Expected Allowed: Actual ', $acl->isAllowed('admin') ? 'Allowed' : 'Denied';
echo 'Expected Allowed: Actual ', $acl->isAllowed('admin', null, 'view') ? 'Allowed' : 'Denied';

@ezimuel
Zend Framework member

Fixed with #4226

@ezimuel ezimuel closed this Apr 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment