feat(federation): add automatic client registration (OpenID Federation 1.0 §12.1) - #259
Merged
Merged
Conversation
…n 1.0 §12.1) Adds AutomaticClientRepository (storage.ClientRepository) and AutomaticClientKeySource (keys.ClientKeySource): an OpenID Provider can accept a Relying Party's own Entity Identifier as client_id with no prior registration step. On a miss from an existing (static) repository, the RP's Trust Chain is resolved via Resolver, and its Resolved Metadata's own openid_relying_party object becomes the client's registration — cached per client, bounded by both a configured max age and the chain's own natural ResolvedEntity.ExpiresAt. Static registration always wins (both types try their own Underlying first), and the two share one resolution/cache so a request touching both ResolveClient and ResolveVerificationKeys for the same client only resolves its chain once. First version deliberately narrow (documented in doc.go and AutomaticClientRepository's own comment): only ClientAuthMethodPrivateKeyJWT (every RFC 8705 mTLS method needs "x5c" from the client's own JWK, which this module's JOSE layer doesn't yet preserve), only an inline "jwks" (no jwks_uri), no CIBA or client_credentials, and no request_uri/JAR/PAR-level enforcement of §12.1.1's own aud/sub/jti Request Object rules (a request-handling concern for a later change, not a client registration one). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017N2kkxv9BR4Qmj8De3Ucs6
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
5 tasks
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
AutomaticClientRepository(storage.ClientRepository) andAutomaticClientKeySource(keys.ClientKeySource) implementing OpenID Federation 1.0 §12.1 "Automatic Registration": an OP can accept a Relying Party's own Entity Identifier asclient_idwith no prior registration step. On a miss from an existing (static) repository, the RP's Trust Chain is resolved viaResolver, and its Resolved Metadata's ownopenid_relying_partyobject becomes the client's registration.ResolvedEntity.ExpiresAt— never trusted longer than the chain itself remains valid.Underlyingdependency first, and the two share one resolution/cache so a single request touching bothResolveClientandResolveVerificationKeysfor the same client only resolves its chain once.openid_relying_partymetadata'sjwks— never from its Entity Configuration's own top-level federation signing key, a distinct key for a distinct purpose perfederation/doc.go. A dedicated test confirmsAutomaticClientKeySourceresolves the right one.Deliberately out of scope for this first version (documented in
doc.goandAutomaticClientRepository's own comment)ClientAuthMethodPrivateKeyJWT— every RFC 8705 mTLS method needs thex5cmember of the client's own JWK, which this module's JOSE layer doesn't currently preserve.jwksobject —jwks_uri(a remote fetch) isn't supported yet.client_credentialsfor automatically-registered clients.aud/sub/jtiRequest Object rules — that's request-handling, not client registration, and is left for a later change.Test plan
go build ./...go test -race ./...golangci-lint run ./...— 0 issuesRegisteredClientConfigmapping (valid + every rejection path, algorithm/encryption pairing), constructor validation for both types, static-registration-wins precedence for both, federation fallback end-to-end over real HTTPS test servers (a genuine two-level TA→RP chain), cache-hit call-counting (the RP's own well-known endpoint is fetched exactly once across two calls within the cache window), and the OIDC-key-vs-federation-key distinction.federationpackage coverage: 98.2%🤖 Generated with Claude Code
https://claude.ai/code/session_017N2kkxv9BR4Qmj8De3Ucs6