Repository navigation
auth: support qop=auth in digest client (#1074) - #1155
Merged
Merged
Conversation
The client never looked at the qop directive of a digest challenge and always computed the legacy RFC 2069 response, so servers that require qop="auth" - as most RFC 7616 implementations do - rejected every request with a 401. Parse qop in WWW-Authenticate, and when the server offers "auth", send qop, cnonce and nc and compute the response as H(HA1:nonce:nc:cnonce:qop:HA2) (RFC 7616, section 3.4.1). The nonce count increases at every request, as required. Challenges without qop keep the previous behavior. auth-int is not implemented. Also copy the opaque value of the challenge into the Authorization header, which RFC 7616 section 3.3 says the client should return unchanged.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1155 +/- ##
=======================================
Coverage 87.17% 87.17%
=======================================
Files 133 133
Lines 10587 10621 +34
=======================================
+ Hits 9229 9259 +30
- Misses 1358 1362 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
i moved the "auth in QOP" check in a dedicated function, added mentioned specifications in the README and merged, thanks! |
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.
Fixes #1074.
The client never looked at the
qopdirective of a digest challenge. It always computed the legacy RFC 2069 response, so a server that requiresqop="auth", which most RFC 7616 implementations do, rejects every request with a 401 and the stream never starts.This parses
qopin WWW-Authenticate and, when the server offersauth, sendsqop,cnonceandncand computes the response asH(HA1:nonce:nc:cnonce:qop:HA2)(RFC 7616, section 3.4.1). The nonce count increases on every request that reuses the nonce, and the client nonce stays constant for the session. Challenges withoutqopkeep the exact previous behavior, andauth-intis not implemented, it falls back to the legacy computation.The response formula is pinned by the test vectors in RFC 7616 section 3.9.1, which I used as the expected values in the header round-trip test.
While in there, the
opaquevalue of the challenge is now copied into the Authorization header. It was already parsed and marshalable but never set; RFC 7616 section 3.3 says the client should return it unchanged.The server side of this package does not advertise or verify
qop, which is why the existing round-trip tests never caught this. I left that out to keep the change focused, happy to follow up if you want it.