Repository navigation
Description
Delegated access (#6406 "Delegated client access to a user's connections") will let a delegated token read a stored upstream OAuth credential when it carries the delegated-access marker (#6404 "Add a delegated-access marker that gates credential lookup for approved delegated tokens"). That marker is trustworthy for credential lookup only when the token carrying it was validated as issued by the embedded ToolHive authserver that owns the credential namespace.
Note: an earlier PR for this issue (#6458) was closed; this needs a new PR.
This issue prepares the configuration and trust-enforcement seams for that capability. It does not implement platform-user storage, a functioning UserTokenReader, or agent credential retrieval.
Compatibility contract
Existing deployments must see zero runtime behavior change on upgrade.
Add upstreamCredentialScope to EmbeddedAuthServerConfig (cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types.go, alongside PrimaryUpstreamProvider and DisableUpstreamTokenInjection):
session(permanent default): today's behavior, unchanged. The existing session-basedTokenReaderremains wired exactly as it is today.UserTokenReaderremains nil, so none of the new issuer checks run.platformUser: explicit opt-in to the future durable-user credential model. In this preparatory issue the value is validated and propagated, but runtime activation must fail explicitly as unsupported until the storage-layer issue supplies and wires a functioningUserTokenReader.
Use +kubebuilder:default=session. An object that omits the field, including every object created before this field existed, behaves identically to one that explicitly sets session. The default is permanent; there is no plan to flip it in a later release.
Only a genuinely absent value maps to session. Reject unknown non-empty values; never silently reinterpret a garbage value as the default.
The effective-default rule must also exist in Go configuration handling. Kubernetes defaulting does not cover old serialized RunConfigs, direct vMCP YAML, or direct Go construction.
Scope: trust plumbing only
Introduce a distinct UserTokenReader capability for future durable platform-user lookup, separate from the existing session-based TokenReader.
This issue must:
- Add and propagate
upstreamCredentialScopethrough the shared embedded-authserver RunConfig used by the proxy runner and vMCP. - Preserve all existing
TokenReader,WithUpstreamTokenReader,MiddlewareRunner.GetUpstreamTokenReader, and session/tsidbehavior without signature or semantic changes. - Add the
UserTokenReaderinterface/option seam needed by the later storage work. - Reuse the existing embedded-authserver issuer option (
WithEmbeddedAuthServerIssuer,pkg/auth/token.go~574) for the issuer precondition instead of adding a new field. - Make
NewTokenValidatorenforce the strict issuer precondition only when a non-nilUserTokenReaderis supplied. - Add scope-gated operator and vMCP configuration validation so the same issuer rule is ready at every entry point.
- Reject runtime activation of
platformUseras unsupported until the separate storage implementation can construct and wire a realUserTokenReader. Do not silently start in session mode and do not install a no-op reader.
The later storage issue will remove the unsupported activation error when it implements platform-user row semantics and wires the reader.
Trust precondition
When UserTokenReader is non-nil:
- The embedded-authserver issuer (from
WithEmbeddedAuthServerIssuer) must be non-empty. - The incoming OIDC issuer validated by the token validator must exactly equal it.
- Mismatch or absence is a constructor error.
- There is no fallback to the session reader.
For session scope, UserTokenReader is nil and these checks do not execute.
Example:
scope omitted/session
incoming issuer: https://login.corp.example
embedded AS: https://auth.example
-> preserve existing runtime behavior
scope platformUser
incoming issuer: https://login.corp.example
embedded AS: https://auth.example
-> reject the new capability configuration
scope platformUser
incoming issuer: https://auth.example
embedded AS: https://auth.example
-> trust validation succeeds, then runtime reports that
platform-user storage is not yet implemented by this issue
Operator validation
Update validateOIDCConfigForEmbeddedAuthServer in cmd/thv-operator/pkg/controllerutil/authserver.go carefully:
- Preserve all existing session-mode validation behavior.
- Apply the new issuer-presence and exact-equality checks only when the effective scope is
platformUser. - Do not gate or otherwise change existing audience/resource checks that already apply to session mode.
The operator should surface invalid platformUser trust configuration before rollout. Session-mode resources, including legacy resources with absent, empty, or mismatched issuers that were previously accepted, must not acquire a new failure solely because of this issue.
vMCP CLI validation
pkg/vmcp/cli/serve.go currently does not call ValidateAuthServerIntegration after side-loading the embedded authserver configuration.
Call it, but gate the newly introduced issuer-presence/equality requirements inside ValidateAuthServerIntegration on effective scope platformUser. Calling the validator must not make existing session-mode vMCP configuration fail after upgrade.
Runtime configuration
Add the scope to the shared authserver.RunConfig, because both proxy runner and vMCP consume that configuration.
Runtime rules:
- omitted/empty -> effective
session; session-> existing runtime behavior;platformUser-> validate trust configuration, then return an explicit unsupported-capability error until the storage implementation lands;- any other non-empty value -> configuration error.
An older runtime must not silently ignore an explicitly configured platformUser capability. If current RunConfig version handling cannot guarantee that, add an explicit required-capability/version check rather than relying on unknown-field behavior.
Existing runner behavior
The existing reader in pkg/runner/runner.go is not discarded: it is stored on the runner and obtained by the auth middleware through GetUpstreamTokenReader. Leave that path unchanged.
This issue adds a separate future UserTokenReader seam. It must not convert, wrap, or reinterpret the existing session reader as proof of platform-user trust.
Acceptance tests
Compatibility
- Omitted scope behaves identically to explicit
session. - Session mode preserves the existing session
TokenReaderwiring. - Session mode never constructs or attaches
UserTokenReader. - Session mode does not run the new issuer-presence/equality checks.
- Existing session-mode operator and vMCP configurations with mismatched issuers retain their previous result.
- Existing public session-reader APIs and generated mocks remain source-compatible.
Enum/config propagation
- CRD schema accepts
sessionandplatformUserand defaults omission tosession. - Direct RunConfig handling maps only empty to
session. - Unknown non-empty values fail validation.
- CRD-to-RunConfig conversion preserves the selected value for MCPServer and VirtualMCPServer paths.
Trust boundary
Using a mock UserTokenReader supplied directly to NewTokenValidator:
- matching incoming and authserver issuers succeeds;
- empty incoming issuer fails;
- empty authserver issuer fails;
- mismatched issuers fail;
- a trailing-slash/string mismatch fails exactly rather than being normalized;
- no
UserTokenReaderpreserves legacy constructor behavior.
Dormant platform-user activation
platformUserwith invalid issuer configuration fails with the actionable trust error.platformUserwith valid issuer configuration fails explicitly as unsupported until storage support lands.- It never falls back to session lookup and never installs a no-op reader.
Explicitly out of scope
- Platform-user storage keys or authoritative row/pointer design.
- A functioning
UserTokenReaderimplementation. - Construction or runtime wiring of a real
UserTokenReader. - Reading credentials by the delegated-access marker or canonical user ID (Ownership-checked credential read for delegated tokens, keyed by user and routed provider #6407).
- One-row-per-
(platformUser, provider)write semantics. - Account replacement, refresh compare-and-swap, rollback, logout, and revocation semantics.
- Storage migration or mode-switch tooling.
- Per-agent/
act.subcredential binding.
Those behaviors belong to the dependent storage and agent-credential issues. This issue only establishes a backward-compatible configuration surface and a fail-closed trust seam that those later changes must use.
Files
Expected areas include:
cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types.go— enum and field.- Generated CRDs/deepcopy/operator API documentation.
pkg/authserver/config.go— serialized scope, effective default, and validation.cmd/thv-operator/pkg/controllerutil/authserver.go— CRD-to-RunConfig propagation and scope-gated cross-config validation.pkg/auth/token.go— separateUserTokenReaderoption and conditional issuer validation.pkg/runner/runner.go— preserve existing session reader; reject unsupportedplatformUseractivation until storage wiring exists.pkg/vmcp/config/validator.goandpkg/vmcp/cli/serve.go— scope-gated validation with no session-mode behavior change.- Unit and operator integration tests for compatibility, propagation, and dormant activation.
Activity
[-]Enforce token-validator trust precondition for the AS issuer everywhere it's wired[/-][+]Add upstreamCredentialScope opt-in and enforce its issuer trust[/+]jhrozek commentedon Nov 24, 2026
Closing as superseded. There's no keying setting any more: Go embedders
opt in with a typed option ("User-keyed upstream storage behind the
embedder option" (#7263)), and runner-built deployments move to per-user storage
in "Re-authorization walks the full upstream chain instead of evaluating existing credentials" (#6831). Two leftovers: the missing
ValidateAuthServerIntegrationcallin
pkg/vmcp/cli/serve.gomoved to the new issue. Refusing user keyingwith a synthetic first upstream is not carried over: a synthetic user has
rows of its own and nothing else reads them.