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

Create role based only on instance #488

Closed
Kani999 opened this issue Jun 6, 2018 · 5 comments
Closed

Create role based only on instance #488

Kani999 opened this issue Jun 6, 2018 · 5 comments

Comments

@Kani999
Copy link

Kani999 commented Jun 6, 2018

Is there an option to create roles that we can assign to instances only but not to the whole class?

I want to define a role scoped to a resource instance:

user = User.find(2)
user.add_role :moderator, Forum.first

But I want to disable defining role's scoped to a whole class

user = User.find(3)
user.add_role :moderator, Forum

Is there any way, that I can forbid the second choice?

@EppO
Copy link
Member

EppO commented Feb 27, 2019

Currently the only way to prevent it is through your application code. Rolify won't enforce it for you.
More generally, rolify's goal is to integrate with an authorization library, not to enforce any policies or rules.

@Kani999
Copy link
Author

Kani999 commented Mar 12, 2019

@EppO Thanks
I've already written my own library to override some actions that fit my use case.

So I'm closing the ticket.

@Kani999 Kani999 closed this as completed Mar 12, 2019
@EppO
Copy link
Member

EppO commented Mar 13, 2019

Can you share your library? If it integrates with rolify, I can link it in the README like Cancan and Pundit

@Kani999
Copy link
Author

Kani999 commented Mar 14, 2019

@EppO
I've created a repository with some description of how my library works.
It's nothing revolutionary and bullet-proof, but it's possible that it might help someone.

Here's a link https://github.com/Kani999/rolify_restrictions

@Kani999
Copy link
Author

Kani999 commented Mar 15, 2019

@EppO
I added a docker-compose template to the repository above. So you could try the library.
Please try to run the Docker. It is my first template, so I hope it will work.

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

2 participants