Resolve user info from token claims; drop /api/external/userinfo dependency - #161
Draft
petrikero wants to merge 1 commit into
Draft
Resolve user info from token claims; drop /api/external/userinfo dependency#161petrikero wants to merge 1 commit into
petrikero wants to merge 1 commit into
Conversation
petrikero
force-pushed
the
feat/userinfo-from-token-claims
branch
from
June 22, 2026 16:45
569d4e1 to
ec1ce78
Compare
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.
Draft / proposal — opening for discussion before polishing. See open questions at the bottom.
Motivation
The portal is sunsetting
/api/external/userinfo. An endpoint can only be deleted once its last caller is gone, so a partial migration buys nothing toward that goal. This removes every CLI invocation of it, sourcing the user profile from the token claims the CLI already holds.What it does
auth.FetchUserInfo(HTTP GET toUserInfoEndpoint) is replaced byauth.ResolveUserInfo(tokenSet), which reads claims locally — no network call:sub, plus the Metaplay-namespacedhttps://schemas.metaplay.io/email.email,given_name,family_name,name— overrides where present.sub(+ namespaced email if present).Callers updated:
get kubeconfig(dynamic): label = resolved email, falling back tosub. The label is cosmetic —target_environment.go:277notes it's "stored in the kubeconfig but not used otherwise"; auth is themetaplay get kubernetes-execcredentialexec plugin.machine-login: success line now showsclientId(already known) instead of a fetched name.auth whoami: resolves from claims.UserInfoEndpointconfig is retained (field, defaults, andmetaplay-project.yamlvalidation) for config compatibility, markedUnusedin code since the CLI no longer calls it.Why the tokens carry this (SDK refs)
AuthUi/src/routes/consent.ts:34-68— setsemail/given_name/family_name/nameon the id_token for human logins (whenemail/profilescopes are granted; the CLI requests both).DeveloperPortal/.../ory/enrichclaims.post.ts:401-411— addshttps://schemas.metaplay.io/{email,roles}to both tokens; the CLI client is not in the portal ignore-list.Impact
whoamino longer showspicture(not in any token); machinewhoami/machine-loginshowclientId/subrather than a name.whoami --format jsonwill have an emptypicture.Verified live
auth whoami -von a real session: resolves from claims with no network call (instant),emailpopulated from the namespaced access-token claim even without an id_token,subpresent. Unit coverage added inlogin_test.go(human id-token, machine access-token, id-token override, no-subject error).Open questions for review
get kubeconfig'sAUTH_PROVIDERarg is now unused (its only role was selecting the userinfo endpoint). Kept registered for compatibility — remove it, or keep as a no-op?picturefromwhoamiacceptable? (Alternative: keep a singlewhoami-only call to the non-deprecated/api/v1/users/me.)enrichclaims, which the portal itself plans to deprecate. Standard id-tokenemailis the durable human source; machines would lose email if that webhook goes away. Acceptable, or do machines need a successor endpoint?UserInfoEndpointis retained but unused — keep it indefinitely for config compatibility (current choice), or plan removal later?