nathanl / authority

*CURRENTLY UNMAINTAINED*. Authority helps you authorize actions in your Rails app. It's ORM-neutral and has very little fancy syntax; just group your models under one or more Authorizer classes and write plain Ruby methods on them.
MIT License
1.21k stars 67 forks source link

Remove Rails dependency #29

Closed christhekeele closed 11 years ago

christhekeele commented 11 years ago

Looking through the source, Authority isn't tied too tightly to Rails. ActiveSupport's the core Rails library being used.

While the Railtie and generators are nice, you could use a configuration or auto-detection mechanism to load those on demand/need.

ORM agnosticism is nice, but framework-agnosticism? That's great!

Plus an abstracted framework integration layer would make it easier for people (cough) to contribute new integrations.

christhekeele commented 11 years ago

Actually it looks like it is made to run without rails, but the gemspec doesn't give you the option.

nathanl commented 11 years ago

@christhekeele - I'd love to have Authority usable with other frameworks, but I haven't needed the feature yet myself, so I haven't looked into it.

Is this something you want to take a crack at?

christhekeele commented 11 years ago

I'm doing so now, actually, trying to layer it on top of Padrino. I'll let you know how it goes!

christhekeele commented 11 years ago

The core Authority methods do work fine without Rails. The controller helpers, on the other hand, are obviously pretty specific to Rails.

I couldn't really find way to make the controller helpers cleanly decoupled from the framework. It'll either involve a lot of duplication or polluting your pretty clean logic with ugly variable names to achieve the decoupling. I figured the latter was better than the former.

My branch has two commits on it: the first decoupling the strict requirements on Rails for those who might just want the Model and Authorizer functionality; the second playing around with controller decoupling and auto-detecting. Take a look and tell me what you think.