Repository navigation
Conversation
`HTTPDigestAuthHandler` and `ProxyDigestAuthHandler` only looked at the first `WWW-Authenticate` / `Proxy-Authenticate` header and took its first word as the scheme. As a result: * A Digest challenge was ignored if a Basic challenge came first, in the same header or in an earlier one. * An unsupported scheme listed first (for example `Kerberos, Basic realm="x"`) raised `ValueError`. Because the Digest handler runs before the Basic handler, that also blocked `HTTPBasicAuthHandler`. This PR changes only `AbstractDigestAuthHandler`. `AbstractBasicAuthHandler` already handles multiple challenges since pythonGH-18284 and is not modified. * `http_error_auth_reqed()` now reads all headers (`get_all()`) and uses the first Digest challenge found. It raises `ValueError` only when neither Digest nor Basic is offered; otherwise it returns `None` so the next handler can try. * A new private `_parse_challenges()` splits a header into challenges per RFC 9110 §11.6.1. A comma-separated element that starts with a word not followed by `=` begins a new challenge. Its quote/escape handling matches `parse_http_list()`. It makes a single linear pass with no regex. * `retry_http_digest_auth()` is unchanged. It receives the original text of the Digest challenge, so escapes are not processed twice. For a single-challenge header the string is the same as before. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HTTPDigestAuthHandlerandProxyDigestAuthHandleronly looked at the firstWWW-Authenticate/Proxy-Authenticateheader and took its first word as the scheme. As a result:A Digest challenge was ignored if a Basic challenge came first, in the same header or in an earlier one.
An unsupported scheme listed first (for example
Kerberos, Basic realm="x") raisedValueError. Because the Digest handler runs before the Basic handler, that also blockedHTTPBasicAuthHandler.This PR changes only
AbstractDigestAuthHandler.AbstractBasicAuthHandleralready handles multiple challenges since GH-18284 and is not modified.http_error_auth_reqed()now reads all headers (get_all()) and uses the first Digest challenge found. It raisesValueErroronly when neither Digest nor Basic is offered; otherwise it returnsNoneso the next handler can try.A new private
_parse_challenges()splits a header into challenges per RFC 9110 §11.6.1. A comma-separated element that starts with a word not followed by=begins a new challenge. Its quote/escape handling matchesparse_http_list(). It makes a single linear pass with no regex.retry_http_digest_auth()is unchanged. It receives the original text of the Digest challenge, so escapes are not processed twice. For a single-challenge header the string is the same as before.🤖 Generated with Claude Code
I have reviewed the logic and changes done by claude. This is the most compact way to address requirement in the long pending issue gh-59515