RolifyCommunity / rolify

Role management library with resource scoping
https://rolifycommunity.github.io/rolify/
MIT License
3.16k stars 404 forks source link

Suggestion: roles `has_and_belongs_to_many :roles` #31

Open hazah opened 12 years ago

hazah commented 12 years ago

I suggest adding another layer to roles such that each role can have and belong to many other roles (essentially, a role should behave much like a user. This will allow for aggregation of roles and allow for more flexible designs. Of course, the client should not be forced to have any sort of hierarchy, merely have an API that allows for role composition.

EppO commented 12 years ago

Thanks for the suggestion, what would be the use case of that feature ? What would it give to have a role connected to another role ? A user can already have many roles, independent from each other. I don't see the added value of a "cascading" role schema. A detailed use case would help me to understand the scope and details of the feature you want.

hazah commented 12 years ago

A cascading role schema allows one to express more abstract roles. "Role Types" if you will. A site_administrator role can have administrator roles on certain objects while not on others, while a root role can have administrator roles on all objects, for instance. This will allow one to pick and choose groupings more easily. A good use case is of course, authorisation. Though your system isn't really tied to any one solution, the existing solutions are one place to look. As an example, have a look at declarative_authorisation, where role groups are utilised for incremental role applications. I'll be happy to answer any more questions you may have

EppO commented 12 years ago

I need some time to think about this one. I plan to release v3.0 with Mongoid support and roles search on resources first. I will consider this feature as a v3.1 candidate.

hazah commented 12 years ago

Let me know if you wish to bounce ideas off of me. I'd love to get involved :).

EppO commented 12 years ago

Feel free to add some specs about your ideas, creating a dedicated branch for that feature. Any help or idea greatly appreciated :-)

EppO commented 12 years ago

I'am planning to introduce a plugin architecture in rolify 4.0, that's a feature I would like to consider for this release.

hazah commented 12 years ago

Cool. I have a number more brewing. My long disappearance is due to the fact that some of my own requirements have changed and I went back to the drawing boards. Is there more info about the kind of plugins you're thinking?

EppO commented 12 years ago

So far, I'm thinking about 2 plugins: this one and another providing weight to each role, in order to rank them. rolify 4.0 implementation is not started yet though. I have to finish a release for 3.x branch first.

hazah commented 12 years ago

No problem. If this plugin system makes your roles generic enough, I'm concidering using this gem in a CMS project.