Skip to content

Implement full RFC 7616 HTTP Digest Authentication compliance - #2148

Merged
hyperxpro merged 3 commits into
mainfrom
rfc-7616
Mar 15, 2026
Merged

Implement full RFC 7616 HTTP Digest Authentication compliance#2148
hyperxpro merged 3 commits into
mainfrom
rfc-7616

Conversation

@hyperxpro

Copy link
Copy Markdown
Member

Motivation:
Achieve full RFC 7616 compliance for HTTP Digest Authentication — supporting stale nonce recovery, nonce count tracking, userhash, Authentication-Info processing, multiple challenge negotiation, algorithm-aware auth-int, and Proxy-Authenticate parity.

Modification:

  • Add stale, userhash, entityBodyHash fields to Realm/Realm.Builder; replace quoted-only match() with matchParam() supporting both quoted and unquoted header values; fix parseProxyAuthenticateHeader to match parseWWWAuthenticateHeader parity for charset, qop, stale, and userhash.
  • Add NonceCounter for thread-safe nc tracking, selectBestDigestChallenge() for multi-challenge negotiation, computeUserhash()/computeRspAuth() helpers; wire stale-nonce retry, nc increment, auth-int body hashing, and Authentication-Info nextnonce/rspauth processing into both 401/407 interceptors via shared NonceCounter.

Result:
Fixes #2068

pratt4 and others added 3 commits March 15, 2026 09:44
This is build on top of
#2089

and still some changes are required around new testcases and failing
testcases

closes #2068

---------

Co-authored-by: Aayush Atharva <aayush@shieldblaze.com>
@hyperxpro

Copy link
Copy Markdown
Member Author

@pratt4 - Finally rolling :)

@hyperxpro
hyperxpro merged commit 4168dd1 into main Mar 15, 2026
6 checks passed
@hyperxpro
hyperxpro deleted the rfc-7616 branch March 15, 2026 11:47
hyperxpro pushed a commit that referenced this pull request Jul 25, 2026
Realm.Builder.ha2 writes A2 into the recycled StringBuilder that
newResponse took from StringBuilderPool, but on the auth-int branch with
no precomputed entity-body hash it called StringUtils.toHexString, which
takes that same thread-local builder and resets it. The "POST:/secret:"
already written was discarded and A2 came out as the empty-body hash
twice, so the Digest response no longer bound the request method or the
target URI. Appending with appendBase16 keeps the hash in the buffer
already being built, which is what ha1 and newResponse already do for
HA1 and HA2. The two encoders emit identical lowercase, zero-padded hex,
so the digest is unchanged everywhere the branch was already correct.

Latent since #2148 replaced the EMPTY_ENTITY_MD5 constant with a
computed hash. The null-entityBodyHash branch is no longer reachable
from the request pipeline: #2276 wired setEntityBodyHash into
perRequestAuthorizationHeader and computeBodyHash never returns null, so
no wrong header reaches the wire today. It is still reached by the
nextnonce rotation in Interceptors and by Realms built through the
public API. The added RealmTest case checks the response against the
RFC 7616 A2 and fails on the current code.
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.

any plan for RFC7616?

2 participants