Repository navigation
Conversation
formatAuthenticate omitted any auth-param whose value was empty, including the required id, realm, method, intent and request fields. FormatAuthenticateStrict therefore returned no error while emitting a WWW-Authenticate header that this SDK's own ParseChallenge rejects. The strict path now fails with "mpp: missing required <name> auth-param". The lenient FormatAuthenticate returns only a string, so its callers cannot observe an error; its behaviour is deliberately unchanged.
memosr
force-pushed
the
fix/reject-empty-required-auth-params
branch
from
August 17, 2026 09:12
7b66095 to
2676c60
Compare
Contributor
|
Thanks for this! We've carried your change forward in #240. It's rebased onto current main, includes the follow-ups from review, and credits this PR. Closing this one in favor of it. |
brendanjryan
added a commit
that referenced
this pull request
Oct 25, 2026
…s strictly (#240) Supersedes #120 by @memosr (thanks!), rebased onto current main. `formatAuthenticate` drops empty values, including the required `id`, `realm`, `method` and `intent`, so `FormatAuthenticateStrict` returned no error for a header that `ParseChallenge` rejects with missing required fields. The conformance vector `error_empty_id_format` expects a format error. Strict formatting now rejects empty required params; the lenient `FormatAuthenticate` is unchanged. - Rebased onto main's opaque handling (`wireOpaque`). Checks: gofmt -l, go vet ./..., go build ./... ./examples/..., go test -race ./..., plus the regression tests run against main (fail) and with the fix (pass). Co-authored-by: memosr <mehmet.sr35@gmail.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.
formatAuthenticateomits any auth-param whose value is empty. That includes the requiredid,realm,methodandintentfields, soFormatAuthenticateStrictreturns no error while emitting aWWW-Authenticatevalue that this SDK's ownParseChallengerejects withmissing required challenge fields.The conformance suite already expects this to fail:
and the Go adapter passes that vector only because it carries a manual guard immediately before calling into the SDK:
That guard becomes unnecessary once the SDK enforces it.
FormatAuthenticatereturns only a string, so its callers cannot observe an error; the lenient path is deliberately unchanged. Optional params (digest,expires,description,opaque) keep being dropped when empty.One caveat worth naming:
protocol.schema.jsonsetsminLength: 1onid,methodandintentbut not onrealm, so an empty realm is not a schema violation. It is still treated as required here becauseParseChallengerejects a challenge without one.server.Newaccepts an empty realm today, and such a server previously emitted 402s this SDK could not parse; it now surfaces the misconfiguration as a 400 problem document.Reverting the check fails the four new
TestFormatAuthenticateStrictRejectsEmptyRequiredAuthParamssubtests; the "behaviour unchanged" tests pass either way.