Skip to content
This repository has been archived by the owner on May 14, 2018. It is now read-only.

Super role full access #285

Closed
rodrigotavio91 opened this issue Jun 19, 2015 · 3 comments
Closed

Super role full access #285

rodrigotavio91 opened this issue Jun 19, 2015 · 3 comments
Assignees
Labels

Comments

@rodrigotavio91
Copy link

Is there some way to make a role have full access to all actions?

I have a system that uses the BjyAuthorize, but I extended some classes to get the roles, guards and resources from a database. That works pretty well, but I've got to always register the new module on the database to get access to this module, otherwise I got a 403 error, because if the controller and action weren't defined on guards, then there is not permission for them.
So I don't think is cool if I want to create a new controller and action I've got to go there and register both of them even if I neither saw they working.
Even if I not use database and define the guards inside an array on the config file, I'll have to do the same thing: before I test my actions, I got to put them on the config file.

Thanks.

@Ocramius
Copy link
Contributor

Ocramius commented Jul 3, 2015

@rodrigotavio91 Zend\Permissions\Acl allows for null permissions/roles to be assigned, but the resources MUST be registered upfront, regardless.

@Ocramius Ocramius self-assigned this Jul 3, 2015
@Ocramius Ocramius closed this as completed Jul 3, 2015
@rodrigotavio91
Copy link
Author

Yeah, but I solve it in other way. I extended the BjyAuthorize\Service\Authorize and replaced the isAllowed() method. I also have a parameter admin_role in the bjyauthorize.global.config.php, that defines which is the admin role. So, in the isAllowed(), when the role logged in is an admin, the function return true, before call $this->acl->isAllowed()

public function isAllowed($resource, $privilege = null)
{
    $this->loaded && $this->loaded->__invoke();

    if ($this->isAdmin()) {
        return true;
    }

    try {
        return $this->acl->isAllowed($this->getIdentity(), $resource, $privilege);
    } catch (InvalidArgumentException $e) {
        return false;
    }
}

Thanks for your reply.

@danitome24
Copy link

@Ocramius Where can I put the following code to give all permissions to admin?:

$this->acl->allow('admin')

Because if parameter resource is null, all permissions are given to admin.

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

No branches or pull requests

3 participants