Skip to content

gh-60299: Fix ProxyDigestAuthHandler credential lookup to use proxy authority - #160528

Merged
orsenthil merged 1 commit into
python:mainfrom
orsenthil:gh-60299
Oct 29, 2026
Merged

orsenthil merged 1 commit into
python:mainfrom
orsenthil:gh-60299

Conversation

@orsenthil

@orsenthil orsenthil commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

AbstractDigestAuthHandler.get_authorization() always looked up credentials using the target request URL (req.full_url), even when invoked via ProxyDigestAuthHandler, whose credentials are registered against the proxy's host:port. The lookup never matched, no Proxy-Authorization header was produced, and proxy digest auth always failed with an unhandled 407.

Match ProxyBasicAuthHandler/HTTPBasicAuthHandler: use the proxy's authority (req.host) for the proxy case, and keep using the full URL for ordinary (non-proxy) digest auth so HTTPPasswordMgr's sub-URI realm matching keeps working.

Fixes #60299

  • Tests
  • Added test_proxy_digest_auth, which fails on current main and passes with this fix.
  • Added test_digest_auth_uses_full_url as a regression guard for the non-proxy path.

…roxy authority

AbstractDigestAuthHandler.get_authorization() always looked up
credentials using the target request URL (req.full_url), even when
invoked via ProxyDigestAuthHandler, whose credentials are registered
against the proxy's host:port.

The lookup never matched, no Proxy-Authorization header was produced,
and proxy digest auth failed with an unhandled 407.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Fix urllib2_localnet test cases.
@orsenthil orsenthil added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 29, 2026
@orsenthil
orsenthil merged commit 9b3e095 into python:main Oct 29, 2026
57 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @orsenthil for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 29, 2026

Copy link
Copy Markdown

GH-160914 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 29, 2026
@bedevere-app

bedevere-app Bot commented Oct 29, 2026

Copy link
Copy Markdown

GH-160915 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 29, 2026
orsenthil added a commit that referenced this pull request Oct 29, 2026
…proxy authority (GH-160528) (#160914)

gh-60299: Fix ProxyDigestAuthHandler credential lookup to use proxy authority (GH-160528)

AbstractDigestAuthHandler.get_authorization() always looked up
credentials using the target request URL (req.full_url), even when
invoked via ProxyDigestAuthHandler, whose credentials are registered
against the proxy's host:port.

The lookup never matched, no Proxy-Authorization header was produced,
and proxy digest auth failed with an unhandled 407.
(cherry picked from commit 9b3e095)

Co-authored-by: Senthil Kumaran <senthil@python.org>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
orsenthil added a commit that referenced this pull request Oct 29, 2026
…proxy authority (GH-160528) (#160915)

gh-60299: Fix ProxyDigestAuthHandler credential lookup to use proxy authority (GH-160528)

AbstractDigestAuthHandler.get_authorization() always looked up
credentials using the target request URL (req.full_url), even when
invoked via ProxyDigestAuthHandler, whose credentials are registered
against the proxy's host:port.

The lookup never matched, no Proxy-Authorization header was produced,
and proxy digest auth failed with an unhandled 407.
(cherry picked from commit 9b3e095)

Co-authored-by: Senthil Kumaran <senthil@python.org>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

urllib2 failing with squid proxy and digest authentication

1 participant