Live data from Hacker News

Role-based authorization in Rails

blog.chaps.io

11–20 of 24 posts

Re: Role-based authorization in Rails

#13

I've been using Pundit, which is model-based, rather than role-based, and it works really nicely with Rails conventions. Model-based feels more natural than role based, IMO.

I've used Pundit in my last few projects and loved the simplicity of it. Would recommend to others.

Re: Role-based authorization in Rails

#15
post #10

I do like the access-granted DSL. It seems to address some of CanCan's problems on larger more complex projects. Also... if you prefer a more OO style, I wrote a 50 line authorization lib that has proved workable on some of my larger projects. https://github.com/hopsoft/perm

Nice work - your OO style and wrapper is well done. And the OO style makes it easier to do dynamic roles, such as DCI.

Re: Role-based authorization in Rails

#16

I've been using Pundit, which is model-based, rather than role-based, and it works really nicely with Rails conventions. Model-based feels more natural than role based, IMO.

Indeed, the author is framing Access Granted against CanCan/CanCanCan, when Pundit has already picked up the torch of Rails authorization.

Pundit made the design decision to be as close to pure Ruby as possible, and therefore is extremely flexible (similar to the design philosophy of Strong Parameters). Access Granted seems like a step backwards (toward a DSL) from Pundit. So it would take a strong argument to show why Access Granted is preferable to Pundit.

Re: Role-based authorization in Rails

#17
post #2

I think the pattern that needs to be explored is a rails engine that has a web interface to manage permissions for different models. Usually stakeholders want to control the roles and permissions.

Neat idea, you might be able to quickly throw together a really compelling proof-of-concept by building off of https://github.com/RolifyCommunity/rolify, which seems to strike a nice balance of opinionated, flexible, and doing a fair amount of work for you (IE it gets involved in / takes care of the db data modeling).

Re: Role-based authorization in Rails

#18
post #8

Earlier quoted context omitted.

I thought CanCan was abandoned when Rbates took some time off? https://github.com/ryanb/cancan

What happened with that guy? Did he ever come back?

Yeah, he's back online, but hasn't done any more casts or OSS work.

Re: Role-based authorization in Rails

#19

I've been using Pundit, which is model-based, rather than role-based, and it works really nicely with Rails conventions. Model-based feels more natural than role based, IMO.

Pundit is excellent, it doesn't tie you to any one model of authorization, it just gives you a standard way to implement your own in a very light-weight fashion.

Re: Role-based authorization in Rails

#20
post #16

I've been using Pundit, which is model-based, rather than role-based, and it works really nicely with Rails conventions. Model-based feels more natural than role based, IMO.

Indeed, the author is framing Access Granted against CanCan/CanCanCan, when Pundit has already picked up the torch of Rails authorization. Pundit made the design decision to be as close to pure Ruby as possible, and therefore is extremely flexible (similar to the design philosophy of Strong Parameters). Access Granted seems like a step backwards (toward a DSL) from Pundit. So it would take a strong argument to show w…

Yea I thought the same thing when reading this. Pundit is already well adopted and covers this use case, this seems like re-inventing the wheel a bit atm.
Post reply on HN