Ira Herman Ira Herman - 6 months ago 56
Ruby Question

How do I use Devise to secure the delayed_job_web interface?

I'm using the delayed_job_web gem to monitor delayed jobs. https://github.com/ejschmitt/delayed_job_web

It is accessible using this line in my routes.rb:

match "/delayed_job" => DelayedJobWeb, :anchor => false


Every other area of my site requires a login using the Devise gem. How do I make this require a login too?

In the readme, they suggest adding the following to the config.rb:

if Rails.env.production?
DelayedJobWeb.use Rack::Auth::Basic do |username, password|
username == 'username'
password == 'password'
end
end


But that just uses plain text browser authentication.

UPDATE:
I tried something similar to the railscast on resque, and I think it's on the verge of working but giving me a redirect loop now:

authenticate :admin do
mount DelayedJobWeb, :at => "/delayed_job"
end


Any thoughts on why would it be giving a redirect loop?

Thanks,

Answer

Use authenticated instead of authenticate as described here: http://excid3.com/blog/rails-tip-5-authenticated-root-and-dashboard-routes-with-devise/

Works for me!

Comments