Skip to content

Instantly share code, notes, and snippets.

@CarlosCD
Created October 8, 2012 21:37
Show Gist options
  • Save CarlosCD/3855161 to your computer and use it in GitHub Desktop.
Save CarlosCD/3855161 to your computer and use it in GitHub Desktop.
Delayed_job_web Basic Authentication filtering access by hostname and IP address
# Use SSL!
# And place in production.rb:
HOST_NAME = 'localhost:3000'
IP_ADDRESS = '10.17.1.125'
USER_NAME = 'johnny'
PASSSWORD = 'BeGood'
if Rails.env.production?
class SillyAuth < Rack::Auth::Basic
def call(env)
return unauthorized unless (env['HTTP_HOST'] == HOST_NAME) && (env['REMOTE_ADDR'] == IP_ADDRESS)
super(env)
end
end
DelayedJobWeb.use SillyAuth do |username, password|
username == USER_NAME && password == PASSSWORD
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment