Skip to content

Instantly share code, notes, and snippets.

@MatiasFernandez
Created December 16, 2014 15:16
Show Gist options
  • Save MatiasFernandez/f60255d6993ca1856c1d to your computer and use it in GitHub Desktop.
Save MatiasFernandez/f60255d6993ca1856c1d to your computer and use it in GitHub Desktop.
Add HTTP Basic Auth to any environment except Development and Test to Rails App
unless Rails.env.development? || Rails.env.test?
YourApplication::Application.configure do |config|
config.middleware.insert_after(::Rack::Lock, "::Rack::Auth::Basic", "Application Name") do |u, p|
[u, p] == [ENV['HTTP_USER'], ENV['HTTP_PASSWORD']]
end
end
end
# Configure Heroku ENV variables
heroku config:add HTTP_USER='foo' HTTP_PASSWORD='bar' -a myapp-staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment