Skip to content

fix(PasswordConfirmationMiddleware): Make more robust#56015

Draft
joshtrichards wants to merge 4 commits intomasterfrom
jtr/fix-pw-confirm-robustness
Draft

fix(PasswordConfirmationMiddleware): Make more robust#56015
joshtrichards wants to merge 4 commits intomasterfrom
jtr/fix-pw-confirm-robustness

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Oct 26, 2025

  • Resolves: #

Summary

This PR differentiates problematic scenarios, detects them earlier, and handles them more gracefully.

It improves robustness against malformed input and makes edge cases observable and actionable via logs and explicit exceptions, while preserving RFC compliance and known backwards compatibility. It adds targeted validation to detect issues sooner and provide clearer errors and logs instead of failing silently or later when root causes are harder to diagnose.

Other changes

  • Expanded test coverage (WIP)
  • Key behavior clarification (new comments/docblocks)
  • Minor code reformatting

Specifics

  • Hardened Basic auth parsing and validation
    • Stricter Basic token extraction (case-insensitive, precise regex)
    • Strict base64 extraction and decoding
    • Maximum base64 token length enforcement
    • Robust username:password extraction
    • UTF-8 payload detection (logged for awareness/troubleshooting)
  • New / improved logging and exceptions
    • Explicit logs/exceptions for token extraction and base64 decoding failures
    • Earlier detection and logging when session loginname is missing
    • Immediate failure when password part is missing from the decoded payload
    • Unsupported encodings (non-UTF-8) are logged to aid troubleshooting (behavior preserved)

TODO

  • Finish updating tests
  • Decide whether to backport or not

Checklist

Make password confirmation middleware more robust.

Add additional logging (for edge cases, troubleshooting).

Maintains RFC compliance.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.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.

1 participant