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

Grandparent inheritance? #17

Closed
eharrow opened this issue Sep 25, 2017 · 3 comments
Closed

Grandparent inheritance? #17

eharrow opened this issue Sep 25, 2017 · 3 comments
Labels
bug To be fixed.

Comments

@eharrow
Copy link

eharrow commented Sep 25, 2017

Accesscontrol seems to support extending permissions from a parent to child but does not seem to support inheriting permissions more than one level up i.e. grandparent -> parent -> child

e.g. viewer -> ops -> admin where viewer has read, ops read/update and admin read/update/delete

accessControl.grant('viewer').readAny('devices');
accessControl.grant('ops').extend('viewer').updateAny('devices');
accessControl.grant('admin').extend('ops').deleteAny('devices');
console.log(`accessControl.getGrants()=${JSON.stringify(accessControl.getGrants())}`);
assert(accessControl.can('ops').readAny('devices').granted);
assert('admin can reay any devices=' + accessControl.can('admin').readAny('devices').granted);

Correct or have I set up my grants incorrectly?

@eharrow
Copy link
Author

eharrow commented Sep 25, 2017

I guess a work around would be

accessControl.grant('viewer').readAny('devices');
accessControl.grant('ops').updateAny('devices');
accessControl.grant('admin').deleteAny('devices').extend('ops');
accessControl.extendRole(['ops', 'admin'], 'viewer');
console.log(`accessControl.getGrants()=${JSON.stringify(accessControl.getGrants())}`);
assert('admin can read any devices=' + accessControl.can('ops').readAny('devices').granted);
assert('admin can read any devices=' + accessControl.can('admin').readAny('devices').granted);

@onury
Copy link
Owner

onury commented Sep 25, 2017

Your grants are perfect. The default behaviour should be full-inheritance. It seems extended roles are not acquired recursively while querying for permissions.

I'll look into it right now.

@onury onury added the bug To be fixed. label Sep 25, 2017
@onury
Copy link
Owner

onury commented Oct 5, 2017

Fixed in v2.0.0

@onury onury closed this as completed Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug To be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants