Skip to content

feat: AsMap helpers and UserInfo algorithm discovery - #164

Merged
osanderson merged 2 commits into
mainfrom
feat/claims-asmap-userinfo-alg-discovery
Aug 26, 2026
Merged

feat: AsMap helpers and UserInfo algorithm discovery#164
osanderson merged 2 commits into
mainfrom
feat/claims-asmap-userinfo-alg-discovery

Conversation

@osanderson

Copy link
Copy Markdown
Collaborator

Summary

  • Adds IDTokenClaims.AsMap() / UserInfo.AsMap(), merging each type's typed fields into a copy of Parameters for 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_time come back as Unix seconds (matching the OIDC wire format, not time.Time's own JSON encoding); auth_time/acr/amr are omitted entirely when the token never carried them, mirroring the same convention internal/token's issuing side already uses.
  • Closes a self-documented gap in DiscoveredMetadata.SupportsAlgorithms: it previously skipped UserInfo entirely because Discover never parsed userinfo_signing_alg_values_supported/userinfo_encryption_alg_values_supported/userinfo_encryption_enc_values_supported. Now parsed into three new DiscoveredMetadata fields and checked the same way RequestObject/JARM/ID-token-encryption already are — only when the caller's own Algorithms.UserInfo (or UserInfoKeyManagement) 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 clean
  • New unit tests: client.TestIDTokenClaimsAsMap*, client.TestUserInfoAsMapMergesSubjectAndParameters, client.TestSupportsAlgorithms*UserInfo*, client.TestDiscoverAcceptsValidDocumentAtRoot extended for the new discovered fields
  • Full local OIDF conformance run (conformance/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)

osanderson and others added 2 commits August 26, 2026 22:48
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>
@sonarqubecloud

Copy link
Copy Markdown

@osanderson
osanderson merged commit 4d17276 into main Aug 26, 2026
8 checks passed
@osanderson
osanderson deleted the feat/claims-asmap-userinfo-alg-discovery branch August 26, 2026 14:56
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.

1 participant