Skip to content

Instantly share code, notes, and snippets.

@virolea
Last active July 28, 2020 16:41
Show Gist options
  • Save virolea/11d13eb56f908058864b8180cbfc0d3c to your computer and use it in GitHub Desktop.
Save virolea/11d13eb56f908058864b8180cbfc0d3c to your computer and use it in GitHub Desktop.
HTTP Basic Auth for Rack applications - Protect Rails app staging environment with HTTP Basic Auth
MyApp::Application.configure do
# Restrict access with HTTP Basic Auth for staging environment
if ENV['STAGING_AUTH']
config.middleware.use Rack::Auth::Basic do |username, password|
ENV['STAGING_AUTH'].split(':') == [username, password]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment