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

acl: add simple role-based ACL plugin #60

Merged
merged 8 commits into from
Jan 7, 2017
Merged

acl: add simple role-based ACL plugin #60

merged 8 commits into from
Jan 7, 2017

Conversation

goto-bus-stop
Copy link
Member

@goto-bus-stop goto-bus-stop commented Sep 1, 2016

Works a bit like:

uw.acl.createRole('moderator', [
  'waitlist.add',
  'waitlist.remove'
]);

uw.acl.createRole('manager', [
  'moderator',
  'waitlist.clear'
]);

uw.acl.allow(user, ['manager']);

user.can('waitlist.add') == true;

Needs a few more functions:

  • deleting roles
  • user.(dis)allow method that calls uw.acl.(dis)allow

And perhaps should also just put ACL roles in the main user model instead of a separate AclUser model.

@fawaf
Copy link
Member

fawaf commented Sep 4, 2016

ohh, very nice.

@goto-bus-stop goto-bus-stop force-pushed the feature/acl branch 5 times, most recently from 77f53bb to 3bae93e Compare September 13, 2016 13:06
@goto-bus-stop
Copy link
Member Author

Thing to think about: what happens when you user.disallow() a role that has not been allowed directly, but is a subrole of the user's role? currently this means the disallow() call would be a no-op.

At least two ways to solve:

  • When disallow() is called with a "subrole", remove the parent role and add its other subroles. Upside: simple; downside: when the parent role is updated, changes aren't automatically propagated to this user anymore.
  • Add a way to specify "exclusion roles", roles that will be ignored when checking if the user is allowed to do something. eg roles: ['user'], exclude: ['waitlist.join'] would return false for user.can('waitlist.join'). Upside: propagates updates as expected; downside: more complex

@goto-bus-stop
Copy link
Member Author

goto-bus-stop commented Sep 23, 2016

Thing to think about: what happens when you user.disallow() a role that has not been allowed directly, but is a subrole of the user's role? currently this means the disallow() call would be a no-op.

I think i'll just ignore this case. A client UI can restrict what can be removed from a user, and only allow removing roles that had been assigned directly. Host should create a new role instead if they want to remove one permission from a user but keep the rest.

@goto-bus-stop
Copy link
Member Author

now just need to make tests work on travis 👀 👀

@goto-bus-stop
Copy link
Member Author

o, that did it 🎉

@goto-bus-stop goto-bus-stop merged commit 80284dc into master Jan 7, 2017
@goto-bus-stop goto-bus-stop deleted the feature/acl branch January 24, 2017 22:19
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

Successfully merging this pull request may close these issues.

2 participants