Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setting up Rack::Auth::Digest::MD5 middleware in Rails
#References:
# https://github.com/zufrieden/stopwatch/blob/master/config/environments/staging.rb
# http://rubydoc.info/github/rack/rack/Rack/Auth/Digest/MD5
# http://www.sitepoint.com/understanding-http-digest-access-authentication/
# http://levick.tumblr.com/post/65244327897/encrypted-http-basic-auth-in-rails-digest-auth
#"Staging" is the 'realm',
# SecureRandom.base64 is the opaque
# "foo" is the username
# "bar" is the password
# Rails will automatically generate the nonce on each request
# The browser will generate the md5 hash as response for digest auth automatically
config.middleware.insert_before 'Rack::Lock', 'Rack::Auth::Digest::MD5', 'Staging', 'opaque' do |user|
{"foo" => "bar"}[user]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.