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

Problem with ACL inheriting (Gentoo, PHP-FPM 5.4) #448

Closed
alexzaporozhets opened this issue Feb 28, 2013 · 7 comments
Closed

Problem with ACL inheriting (Gentoo, PHP-FPM 5.4) #448

alexzaporozhets opened this issue Feb 28, 2013 · 7 comments

Comments

@alexzaporozhets
Copy link

Phalcon\Acl\Exception: Role 'Guests' does not exist in the role list
File=/home/site/stage/_config.php
Line=46
#0 [internal function]: Phalcon\Acl\Adapter\Memory->addInherit('Administrators', Object(Phalcon\Acl\Role))
#1 /home/site/stage/_config.php(46): Phalcon\Acl\Adapter\Memory->addRole(Object(Phalcon\Acl\Role), Object(Phalcon\Acl\Role))
#2 /home/site/stage/_loader.php(63): require_once('/home/site/stag...')
#3 /home/site/stage/index.php(9): require_once('/home/site/stag...')
#4 {main}

$acl = new Phalcon\Acl\Adapter\Memory();
// disallow all resources by default
$acl->setDefaultAction(Phalcon\Acl::DENY);

try {
    // Create some roles
    $roleAdmins = new \Phalcon\Acl\Role("Administrators", "Super-User role");
    $roleGuests = new \Phalcon\Acl\Role("Guests");

    // Add "Guests" role to acl
    $acl->addRole($roleGuests);

    // Add "Administrators" role inheriting from "Guests" its accesses
    $acl->addRole($roleAdmins, $roleGuests);
} catch (\Phalcon\Exception $e) {
    echo get_class($e), ": ", $e->getMessage(), "\n";
    echo " File=", $e->getFile(), "\n";
    echo " Line=", $e->getLine(), "\n";
    echo $e->getTraceAsString();
}
@phalcon
Copy link
Collaborator

phalcon commented Mar 5, 2013

This line must be:

$acl->addRole($roleAdmins, "Guests");

The object-syntax is now supported in 1.0.0

@phalcon phalcon closed this as completed Mar 5, 2013
@alexzaporozhets
Copy link
Author

Ok, but how I can do inheriting from multiple roles?
It did not work properly in 0.9.1

@phalcon
Copy link
Collaborator

phalcon commented Mar 5, 2013

You could call:

$acl->addRole($roleAdmins, "Guests1");
$acl->addRole($roleAdmins, "Guests2");

@alexzaporozhets
Copy link
Author

I tried on latest versions 1.0, roles-inheriting does not work:

setDefaultAction(Phalcon\Acl::DENY); try { // Create some roles $roleAdmins = new \Phalcon\Acl\Role("Administrators", "Super-User role"); $roleManager = new \Phalcon\Acl\Role("Manager"); $roleGuests = new \Phalcon\Acl\Role("Guests"); ``` $acl->addRole($roleGuests); $acl->addRole($roleManager); // Add "Administrators" role inheriting from "Guests" its accesses $acl->addRole($roleManager, "Guests"); $acl->addRole($roleAdmins, "Manager"); $acl->addResource(new Phalcon\Acl\Resource('main'), ['view', 'moderator']); // allow resource for Guests $acl->allow("Guests", 'main', 'view'); echo " Guests: " . $acl->isAllowed("Guests", 'main', 'view'); echo " Manager: " . $acl->isAllowed("Manager", 'main', 'view'); echo " Administrators: " . $acl->isAllowed("Administrators", 'main', 'view'); ``` } catch (\Phalcon\Exception $e) { echo get_class($e), ": ", $e->getMessage(), "\n"; echo " File=", $e->getFile(), "\n"; echo " Line=", $e->getLine(), "\n"; echo $e->getTraceAsString(); } ... Guests: 1 Manager: 0 Administrators: 0

@iforp
Copy link
Contributor

iforp commented Mar 7, 2013

The same problem. Check forum discussion please:
http://forum.phalconphp.com/discussion/103/acl-roles-inheritance

@alexzaporozhets
Copy link
Author

Is any news about this bug?

@phalcon
Copy link
Collaborator

phalcon commented Mar 13, 2013

This is fixed in the 1.0.0 branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants