halogenandtoast/monban — pull request #13 by kmckelvin (2014-03-21 12:31:36+00:00)
Title: Authorization for Rails Routes

In the app I'm working on I needed to mount Sidekiq's web UI with authorized access control. I think it would be good if Monban had some way of constraining routes built in.

I've built the basic `Monban::Constraints::Authorize` to only check that a user is logged in, but overriding the protected `authorize(user)` method makes it extensible by subclassing - so doing ACL checks can be done from there (I've included a test as an example). If the user is unauthorized it simply calls back to the warden failure app.

Authorized routes can be constrained by:
``` ruby
constraints Monban::Constraints::Authorize.new do
get "authenticated" => "users#new", as: :authenticated
end
```

I haven't made changes to documentation for this yet, but if/when the code looks good I'll update the docs as needed.