Last active
August 29, 2015 14:06
-
-
Save gaganawhad/2eac66aec58340f41959 to your computer and use it in GitHub Desktop.
Setting up Rack::Auth::Digest::MD5 middleware in Rails
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
#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