fix(sdk): preserve issuer identity byte-for-byte - #52
Open
RobertoIskandarani wants to merge 1 commit into
Open
Conversation
An authorization server whose issuer identifier legitimately ends in "/" mints tokens whose `iss` carries that slash (RFC 9068). The SDK stripped the trailing slash from the configured issuer before storing it, then passed the stripped form to the token verifier as the expected `iss` — so every otherwise-valid token from such an AS was rejected, with no workaround short of misconfiguring the issuer. RFC 8414 §3.3 requires the metadata `issuer` to be identical to the configured one, and §4 spells the comparison out as code-point-for-code-point with no normalization. Both sides of that check were being stripped too, which masked the first defect during discovery: discovery passed, then verification failed. They are fixed together because fixing either alone moves the symptom rather than removing it. Deriving the `.well-known` URL still drops the terminating slash (RFC 8414 §3.1). That is derivation, not identity, and is deliberately unchanged — `buildMetadataUrl` continues to do it, and the tests pinning that behaviour stay as they are. Migration: if your configured issuer differs from your authorization server's actual identifier by a trailing slash, correct the config. The SDK no longer reconciles them.
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.
An authorization server whose issuer identifier legitimately ends in
/mints tokens whoseisscarries that slash (RFC 9068). The SDK stripped the trailing slash from the configured issuer before storing it, then passed the stripped form to the token verifier as the expectediss— so every otherwise-valid token from such an AS was rejected, with no workaround short of misconfiguring the issuer.Why both halves move together
RFC 8414 §3.3 requires the metadata
issuerto be identical to the configured one, and §4 spells the comparison out as code-point-for-code-point with no normalization. Both sides of that check were stripped too (documentCache.ts), which masked the first defect during discovery: discovery passed, then verification failed. Fixing either alone moves the symptom rather than removing it.What is deliberately unchanged
Deriving the
.well-knownURL still drops the terminating slash (RFC 8414 §3.1). That is derivation, not identity —buildMetadataUrlcontinues to do it, and the tests pinning that behaviour are untouched.Changes
core/client.ts— storeoptions.issuerverbatim.core/fetching/documentCache.ts— keepexpectedIssuerverbatim, and compare the raw metadataissuerfor exact equality.Tests
tests/core/issuerIdentity.test.tscovers both legs: a token whoseisscarries the configured trailing slash verifies, and a metadata document whoseissuerdiffers only by a trailing slash is rejected withMetadataFetchError.Both were mutation-checked — reintroducing the strip in
client.tsfails the first leg.Full suite green: 384 / 42 / 38 / 40 / 124 across the five packages, plus lint and typecheck.
Migration
If your configured issuer differs from your authorization server's actual identifier by a trailing slash, correct the config. The SDK no longer reconciles them.