Avatar Edgar Gonzalez

  • Random
  • Archive
  • RSS

Ruby on Rails :: How to add HTTP basic authentication to your staging app in Heroku

First you set up your staging app following the Heroku’s guide forĀ Managing Multiple Environments for an App

Then edit the config/environments/staging.rb:

#config/environments/staging.rb
MyApp::Application.configure do

  # Basic authentication
  config.middleware.insert_after(::Rack::Lock, "::Rack::Auth::Basic", "My App") do |u, p|
    [u, p] == [ENV['HTTP_USER'], ENV['HTTP_PASSWORD']]
  end

  ...

And finally set the config vars:

heroku config:add HTTP_USER='foo' HTTP_PASSWORD='bar' -a myapp-staging
    • #rails
    • #heroku
    • #authentication
    • #ruby
    • #rack
  • 9 months ago
  • 2
  • Comments
  • Permalink
  • Share
    Tweet

2 Notes/ Hide

  1. oivoodoo likes this
  2. edgar posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

Portrait/Logo

About

Edgar Gonzalez

Father, husband, and software developer. I'm building web applications since 1994 for a living and I love it.

Rubyist, Rails developer since 2006, believer of Agile Development and Lean startups, NoSQL enthusiast.

Born in Caracas - Venezuela, living in New York.

Me, Elsewhere

  • @edgar on Twitter
  • Facebook Profile
  • edgargonzaleznetve on Youtube
  • egg on Flickr
  • edgar on Foursquare
  • Google
  • My Skype Info
  • Linkedin Profile
  • edgar on github

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr