Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Repairing digest authentication in handle_request #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

emarley
Copy link

@emarley emarley commented Jan 19, 2012

Digest authentication stopped working for me sometime since the 0.5 gem. It seems digest_auth needs the result from the first unauthenticated request in order to build the proper headers for digest authentication. This change moves the digest_auth call from the beginning of the second handle_request (when it can't see the results from the first request) to the end of the first handle_request (when it can).

I changed as little as possible. It might make sense to change the case statement at line 157 to something else, since there's now only one case to consider there.

Liz Marley added 2 commits January 18, 2012 16:40
… 0.5 gem.) digest_auth needs the result from the first naive request in order to build the proper headers for digest authentication.
…e it.

This improves performance because only the first request will have to try,
get HTTPUnauthorized, and retry. Subsequent requests can reuse the same nonces.
@emarley
Copy link
Author

emarley commented Jan 20, 2012

You may have specific reasons not to want to use net-http-digest_auth directly. So I understand if you only want to pull the first commit and not the second one.

@devrandom
Copy link
Owner

Sorry for the delay.

I don't mind pulling both, but the dependency on the digest auth gem has to be declared in the Rakefile jeweler config.

@emarley
Copy link
Author

emarley commented Mar 12, 2012

Ah, okay. I haven't worked much with rakefiles. I'll try to sort that out this weekend. Thanks!

@devrandom
Copy link
Owner

Ping?

@emarley
Copy link
Author

emarley commented Jul 15, 2012

Sorry, got drowned in personal stuff. Still aim to do this soon-ish.

On Jul 6, 2012, at 1:45 PM, Dev [email protected] wrote:

Ping?


Reply to this email directly or view it on GitHub:
#19 (comment)

@emarley
Copy link
Author

emarley commented Jul 29, 2012

I think this was the change you wanted. Thanks for your patience.

@paulvt
Copy link

paulvt commented Dec 20, 2017

I had to make the following change on top of the pull request to get it to work:

@@ -179,15 +184,18 @@
           return response
         when Net::HTTPUnauthorized     then
           response.error! unless @user
-          response.error! if req['authorization']
           new_req = clone_req(req.path, req, headers)
           if response['www-authenticate'] =~ /^basic/i
             if disable_basic_auth
               raise "server requested basic auth, but that is disabled"
             end
+            response.error! if req['authorization']
             @authorization = :basic
           else
             @authorization = :digest
            # Need to set up a new digest auth.

Otherwise I got the following (premature) error:

401 "Unauthorized ( The server requires authorization to fulfill the request. Access to the Web server is denied. Contact the server administrator.  )" (Net::HTTPServerException)
/usr/lib/ruby/2.3.0/net/http/response.rb:120:in `error!'
/usr/lib/ruby/vendor_ruby/net/dav.rb:187:in `handle_request'
/usr/lib/ruby/vendor_ruby/net/dav.rb:120:in `request_returning_body'
/usr/lib/ruby/vendor_ruby/net/dav.rb:586:in `get'

ismo1 pushed a commit to ismo1/net_dav that referenced this pull request May 3, 2021
ismo1 added a commit to ismo1/net_dav that referenced this pull request May 3, 2021
Repairing digest authentication in handle_request devrandom#19
ismo1 added a commit to ismo1/net_dav that referenced this pull request May 3, 2021
Repairing digest authentication in handle_request devrandom#19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants