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

Rbac Not Handling Ancestors Beyond Immediate Parent #88

Open
billmbillson opened this issue Aug 14, 2019 · 0 comments
Open

Rbac Not Handling Ancestors Beyond Immediate Parent #88

billmbillson opened this issue Aug 14, 2019 · 0 comments

Comments

@billmbillson
Copy link

In section 17.2.1 of your ebook, you suggest creating roles 'Administrator,' 'Editor,' and 'Viewer.' 'Administrator' inherits permissions from 'Editor' and 'Editor' inherits permissions from 'Viewer.'

Using your code from section 17.2.2, where you add the roles along with their parents and establish a 'post.view' permission to the 'Viewer' role, I then tested to see if a user with the 'Administrator' role would correctly inherit the 'post.view' permission.

// Create Rbac container.
$rbac = new Rbac();

// The following is to tell Rbac to create some parent roles if not exist yet
$rbac->setCreateMissingRoles(true);

// Create role hierarchy
$rbac->addRole('Viewer', ['Editor', 'Author']);
$rbac->addRole('Editor', ['Administrator']);
$rbac->addRole('Author');
$rbac->addRole('Administrator');

// Assign permissions to the Viewer role.
$rbac->getRole('Viewer')->addPermission('post.view');

$rbac->isGranted('Administrator', 'post.view');    // returns false!!

The Rbac returns false when it should return true.

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

1 participant