Created
October 8, 2012 21:37
-
-
Save CarlosCD/3855161 to your computer and use it in GitHub Desktop.
Delayed_job_web Basic Authentication filtering access by hostname and IP address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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