diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-21 05:14:26 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-21 05:14:26 -0800 |
commit | 618cb4429191290b957391c314a55b4d59f381f3 (patch) | |
tree | bef72ad2005a08efb4faa6e8192cec506f591420 /actionpack/lib | |
parent | 1f75a1fea12ead1370113ea1be0272667ab7da88 (diff) | |
parent | 3131a9379766a735a80220fd2e94cb07791bed9c (diff) | |
download | rails-618cb4429191290b957391c314a55b4d59f381f3.tar.gz rails-618cb4429191290b957391c314a55b4d59f381f3.tar.bz2 rails-618cb4429191290b957391c314a55b4d59f381f3.zip |
Merge pull request #4079 from drogus/http_digest_issue
Fix http digest authentication when url ends with `/` or `?`
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/http_authentication.rb | 13 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/request.rb | 8 |
2 files changed, 16 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/metal/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb index 264806cd36..56335a22cb 100644 --- a/actionpack/lib/action_controller/metal/http_authentication.rb +++ b/actionpack/lib/action_controller/metal/http_authentication.rb @@ -192,12 +192,15 @@ module ActionController return false unless password method = request.env['rack.methodoverride.original_method'] || request.env['REQUEST_METHOD'] - uri = credentials[:uri][0,1] == '/' ? request.fullpath : request.url + uri = credentials[:uri][0,1] == '/' ? request.original_fullpath : request.original_url - [true, false].any? do |password_is_ha1| - expected = expected_response(method, uri, credentials, password, password_is_ha1) - expected == credentials[:response] - end + [true, false].any? do |trailing_question_mark| + [true, false].any? do |password_is_ha1| + _uri = trailing_question_mark ? uri + "?" : uri + expected = expected_response(method, _uri, credentials, password, password_is_ha1) + expected == credentials[:response] + end + end end end diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index c5c48ec489..820921252d 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -122,10 +122,18 @@ module ActionDispatch Http::Headers.new(@env) end + def original_fullpath + @original_fullpath ||= (env["ORIGINAL_FULLPATH"] || fullpath) + end + def fullpath @fullpath ||= super end + def original_url + base_url + original_fullpath + end + def media_type content_mime_type.to_s end |