feat: AsMap helpers and UserInfo algorithm discovery - #164
Merged
Conversation
Both types split validated claims into typed fields plus a Parameters catch-all, so a caller wanting the full claim set as one document (display, logging, forwarding) has to re-merge them by hand. That's easy to get subtly wrong: exp/iat/auth_time are OIDC NumericDate claims on the wire (Unix seconds), not time.Time's own JSON encoding, and auth_time/acr/amr need to be omitted rather than zero-valued when the token never carried them. AsMap encodes both rules once, mirroring the same omit-if-absent convention internal/token's own issuing side already uses. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Discover parsed every other algorithm list OIDC Discovery publishes (id_token, request object, JARM, id_token encryption) but not userinfo_signing_alg_values_supported/userinfo_encryption_*_supported, so a mismatched UserInfo algorithm had no fail-fast path at startup — unlike every other algorithm choice, it only ever surfaced later as a verify/decrypt failure mid-flow. DiscoveredMetadata.SupportsAlgorithms now checks the UserInfo triple the same way it already checks RequestObject/JARM/id_token encryption: only when the caller's own Algorithms.UserInfo (or UserInfoKeyManagement) is actually non-zero, so a caller expecting only a plain-JSON UserInfo response is unaffected. Co-Authored-By: Claude Sonnet 5 <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
IDTokenClaims.AsMap()/UserInfo.AsMap(), merging each type's typed fields into a copy ofParametersfor a caller that wants the full validated claim set as one document (display, logging, forwarding) instead of re-deriving the merge by hand.exp/iat/auth_timecome back as Unix seconds (matching the OIDC wire format, nottime.Time's own JSON encoding);auth_time/acr/amrare omitted entirely when the token never carried them, mirroring the same conventioninternal/token's issuing side already uses.DiscoveredMetadata.SupportsAlgorithms: it previously skipped UserInfo entirely becauseDiscovernever parseduserinfo_signing_alg_values_supported/userinfo_encryption_alg_values_supported/userinfo_encryption_enc_values_supported. Now parsed into three newDiscoveredMetadatafields and checked the same wayRequestObject/JARM/ID-token-encryption already are — only when the caller's ownAlgorithms.UserInfo(orUserInfoKeyManagement) is non-zero, so a caller expecting only a plain-JSON UserInfo response sees no change. A mismatched UserInfo algorithm now fails fast at startup instead of surfacing later as a verify/decrypt failure mid-flow.Test plan
go build ./...,go vet ./...,go test ./...all cleanclient.TestIDTokenClaimsAsMap*,client.TestUserInfoAsMapMergesSubjectAndParameters,client.TestSupportsAlgorithms*UserInfo*,client.TestDiscoverAcceptsValidDocumentAtRootextended for the new discovered fieldsconformance/scripts/run-all.sh): AS baseline (57 modules, 4465 conditions, 0 failures), AS message-signing (71 modules, 5975 conditions, 0 failures), RP baseline (22/22 PASSED), RP message-signing (28/28 PASSED)