fix: decode bytes credentials in HTTPDigestAuth to prevent b'...' repr in hashes#7557
Closed
webdevdot wants to merge 1 commit into
Closed
fix: decode bytes credentials in HTTPDigestAuth to prevent b'...' repr in hashes#7557webdevdot wants to merge 1 commit into
webdevdot wants to merge 1 commit into
Conversation
…gestAuth When username or password are bytes, f-string interpolation produces b'...' repr instead of the raw string, causing an incorrect A1 hash value and a malformed Authorization header in digest auth flows. Decode bytes to str via UTF-8 before building A1 and the base header string, mirroring how the basic-auth path handles bytes credentials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
HTTPDigestAuthstoresusernameandpasswordasbytes | str, butbuild_digest_headerinterpolated them directly into f-stringsb'username'(with thebprefix and quotes) instead of the raw string valueAuthorizationheader containsusername="b'user'"instead ofusername="user", which servers rejectChanges
A1and theAuthorizationheader base stringA1 = f"{_username}:{realm}:{_password}") and the header value (username="{_username}") are fixedprepare_urland elsewhere in the codebaseTest plan
HTTPDigestAuth(b"user", b"pass")and confirm the Authorization header containsusername="user"notusername="b'user'"HTTPDigestAuth("user", "pass")(str credentials) still works identicallypytest tests/test_auth.py -v🤖 Generated with Claude Code