Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick samples on securing Resque::Server
require 'resque/server'
class SecureResqueServer < Resque::Server
before do
redirect '/' unless some_condition_is_met!
end
end
require 'resque/server'
class SecureResqueServer < Resque::Server
use Rack::Auth::Basic, "Restricted Area" do |username, password|
[username, password] == ['admin', 'admin']
end
end
@jcarlos

This comment has been minimized.

Copy link

jcarlos commented Jun 8, 2012

An interesting alternative to this is to use an initializer as described in http://asciicasts.com/episodes/271-resque

"We’re not using Devise or any other authentication system in our application so instead we’ll use HTTP Basic Authentication. To do this we’ll create a new initializer in the config/initializers directory called resque_auth.rb."

I have changed a bit the example from ASCIIcasts
/config/initializers/resque_auth.rb:

Resque::Server.use(Rack::Auth::Basic) do |user, password|  
  [user, password] == ["myuser", "secret"]  
end
@donatoaz

This comment has been minimized.

Copy link

donatoaz commented Apr 3, 2018

Oddly enough, the railscast alternative did not do it for me. I had to use @scottwater's second solution .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.