Created
December 16, 2014 15:16
-
-
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
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
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 |
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
# 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