Skip to content

fix: support X-WWW-Authenticate fallback in DigestAuth - #1332

Open
AdityaSreevatsaK wants to merge 2 commits into
pydantic:mainfrom
AdityaSreevatsaK:fix/digest-x-www-authenticate-846
Open

AdityaSreevatsaK wants to merge 2 commits into
pydantic:mainfrom
AdityaSreevatsaK:fix/digest-x-www-authenticate-846

Conversation

@AdityaSreevatsaK

@AdityaSreevatsaK AdityaSreevatsaK commented Nov 12, 2026 •

Copy link
Copy Markdown

Summary

Fixes #846.

Some devices, such as Fronius solar inverters, return the non-standard X-WWW-Authenticate header instead of WWW-Authenticate when requesting Digest authentication.

Currently, DigestAuth ignores this header, preventing authentication from proceeding.

This PR adds support for X-WWW-Authenticate as a fallback while preserving existing behaviour:

  • Prefer the standard WWW-Authenticate header when both are present.
  • Use X-WWW-Authenticate only when the standard header is absent.
  • Ignore invalid authentication challenges and non-401 responses.

Testing:

  • Added regression tests covering both authentication headers, header precedence and invalid challenges.
  • Full test suite passed across Python 3.11 to 3.15.
  • Linting, type checking and security analysis passed.
  • CodSpeed benchmark tests passed, but uploading results from the fork failed due to a 401 authorisation error.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've reviewed the documentation requirements. No documentation changes are needed because this is a bug fix that introduces no new public API.

View guided diff

@veria-ai

veria-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@codspeed

codspeed Bot commented Nov 12, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing AdityaSreevatsaK:fix/digest-x-www-authenticate-846 (48bd10e) with main (f4f65c1)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Re-trigger cubic

This branch has not been deployed

No deployments
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.

Support DigestAuth with "x-www-authenticate" in first response header

1 participant