Skip to content

Normalize Digest authentication parameter names and whitespace - #1305

Open
theamodhshetty wants to merge 1 commit into
pydantic:mainfrom
theamodhshetty:fix/digest-auth-parameter-normalization
Open

theamodhshetty wants to merge 1 commit into
pydantic:mainfrom
theamodhshetty:fix/digest-auth-parameter-normalization

Conversation

@theamodhshetty

@theamodhshetty theamodhshetty commented Nov 1, 2026 •

Copy link
Copy Markdown

Summary

DigestAuth rejects valid challenges such as Digest Realm="example", Nonce="abc". Uppercase optional parameter names can also silently drop qop/opaque or select MD5 instead of the advertised algorithm. Whitespace around = causes the same parsing problem.

RFC 9110 §11.2 defines case-insensitive authentication parameter names and permits whitespace around the separator. Normalize names and surrounding whitespace before looking up parameters, preserving case and whitespace inside quoted values.

Extend the existing SHA-256 RFC vector across individual uppercase parameters and space/tab separators, asserting the same digest. Add a regression for preserving quoted whitespace.

Locally on Python 3.15.0:

  • Before the fix: 21 regression cases fail; the original RFC vector passes.
  • After the fix: all 2,117 tests pass, including 112 authentication tests.
  • scripts/coverage passes at 100% (14,914 statements).
  • scripts/check passes: lock consistency, formatting, mypy, Ruff and unasync consistency.

Hosted CI now passes on Python 3.11–3.15, including package/docs builds, checks and coverage (Test Suite). Automated reviews report no findings. CodSpeed reports 18 unchanged benchmarks and seven skipped benchmarks using baseline results; this does not establish performance for the skipped cases. Human maintainer review is still pending.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion.
  • I've added a test for each change and kept the fix to the Digest challenge parser.
  • Documentation reviewed; no new API or configuration to document.

AI-assisted investigation, implementation and local validation with Codex.

View guided diff

@codspeed

codspeed Bot commented Nov 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing theamodhshetty:fix/digest-auth-parameter-normalization (4c309de) with main (2fc9158)

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.

1 participant