Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behavior in Phalcon\Acl when adding rules with access specified as string vs string[] #11210

Closed
kristofferingemansson opened this issue Dec 9, 2015 · 1 comment
Labels
bug A bug report status: medium Medium

Comments

@kristofferingemansson
Copy link
Contributor

In Phalcon\Acl\Adapter\Memory, when you add rules to the ACL, depending on if you specify the "access" parameter of methods "allow" and "deny" as string or array of strings, the result of method "isAllowed" is later different.

First example with expected result.

$acl = new \Phalcon\Acl\Adapter\Memory();
$acl->setDefaultAction(\Phalcon\Acl::DENY);
$acl->addRole(New \Phalcon\Acl\Role('user'));

$acl->addResource('asd', array('p1', 'p2'));
$acl->allow('user', 'asd', '*');
$acl->deny('user', 'asd', 'p1');

$result = $acl->isAllowed('user', 'asd', 'p2');
var_dump($result); // prints "bool(true)"

Now same example, but this time I supply access parameter to deny method as an array instead.
Result should be the same, but it's not.

$acl = new \Phalcon\Acl\Adapter\Memory();
$acl->setDefaultAction(\Phalcon\Acl::DENY);
$acl->addRole(New \Phalcon\Acl\Role('user'));

$acl->addResource('asd', array('p1', 'p2'));
$acl->allow('user', 'asd', '*');
$acl->deny('user', 'asd', array('p1'));

$result = $acl->isAllowed('user', 'asd', 'p2');
var_dump($result); // prints "bool(false)"

I think problem lies in memory.zep on line 384
https://github.com/phalcon/cphalcon/blob/phalcon-v2.0.9/phalcon/acl/adapter/memory.zep#L384
Compared to line 413, a ! (negation) is missing before isset.

Tested in 2.0.1 and 2.0.9.

Ps. Reference to Phalcon\Acl\Adapter\Memory::_allowOrDeny in Phalcon\Acl\Adapter\Memory::deny, is in wrong case: "_allowordeny". Ds.

@sergeyklay
Copy link
Contributor

Fixed in 2.0.x

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

3 participants