Skip to content

vMCP: implement upstream_inject outgoing auth strategy #3925

Closed
4 of 4 issues completed
Closed

Description

@jhrozek

Overview

This epic implements the upstream_inject outgoing auth strategy for vMCP (RFC-0054). The strategy reads upstream IDP access tokens from identity.UpstreamTokens (a map[string]string populated by the embedded authorization server in Mode B) and injects them as Authorization: Bearer headers on outgoing backend requests. It also extends token_exchange with an optional SubjectProviderName field for RFC 8693 subject resolution from upstream provider tokens.

Background

RFC-0052 extended the auth middleware to populate identity.UpstreamTokens after TH-JWT validation, and RFC-0053 wired the embedded AS into vMCP. However, no outgoing auth strategy currently consumes those upstream tokens — backends requiring upstream provider credentials (e.g., a GitHub MCP server needing a GitHub access token) cannot receive them. This epic completes the pipeline by adding the upstream_inject strategy and the startup validation rules V-01, V-02, and V-06 that guard against misconfiguration.

Task Breakdown

Task ID Title Depends On GitHub Issue #
TASK-001 Phase 1: Core types and sentinel — #4144
TASK-002 Phase 2: Strategy implementations TASK-001 #4145
TASK-003 Phase 3: Startup validation TASK-001 #4147
TASK-004 Phase 4: CRD and converter TASK-001 #4146

Acceptance Criteria

  • upstream_inject strategy reads identity.UpstreamTokens[providerName] and injects Authorization: Bearer on outgoing backend requests
  • ErrUpstreamTokenNotFound sentinel is defined and returned (wrapped with %w) when the provider's token is absent
  • TokenExchangeStrategy uses the upstream provider token as subject when SubjectProviderName is set
  • Startup validation V-01 (no AS present), V-02 (provider not in AS upstream list), and V-06 (empty providerName) fail fast with descriptive errors
  • Kubernetes CRD supports type: upstreamInject with UpstreamInjectSpec.providerName
  • CRD TokenExchangeConfig supports subjectProviderName field
  • UpstreamInjectConverter converts CRD resources to BackendAuthStrategy
  • All new types have SPDX headers, kubebuilder markers, and deepcopy regenerated
  • All linked task issues completed

References

Sub-issues

Sub-issues

4 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    enhancement
    on Feb 20, 2026
  2. changed the title [-]vMCP: implement embeddedAuthServer outgoing auth strategy[/-] [+]vMCP: implement upstream_inject outgoing auth strategy[/+] on Mar 12, 2026
  3. self-assigned this
    on Mar 12, 2026
  4. added
    vmcp
    go
    on Mar 13, 2026
  5. tgrunnagle commented on Mar 13, 2026

    @tgrunnagle
    Collaborator

    Intake: vMCP Upstream Inject Outgoing Auth Strategy (RFC-0054)

    Original Requirements

    Implement RFC-0054: vMCP Upstream Inject Outgoing Auth Strategy. This RFC implements the upstream_inject outgoing auth strategy for the vMCP component. The strategy reads a named upstream provider's access token from identity.UpstreamTokens (populated by the auth middleware after TH-JWT validation in Mode B) and injects it as an Authorization: Bearer header on outgoing backend requests. It also adds an optional subjectProviderName enhancement to token_exchange for RFC 8693 subject resolution from upstream tokens.

    The implementation is broken into 4 phases:

    • Phase 1: Core types and sentinel (no behavior change)
    • Phase 2: Strategy implementations
    • Phase 3: Startup validation
    • Phase 4: CRD and converter

    A placeholder epic issue exists at #3925. One GitHub issue should be created per phase, linked as sub-issues of #3925.

    Existing Documentation

    • RFC-0054: vMCP Upstream Inject Outgoing Auth Strategy — /Users/trey/Documents/GitHub/toolhive/docs/proposals/THV-0054-vmcp-upstream-inject-strategy.md — Full RFC covering problem statement, detailed design (type changes, new strategy, factory changes, startup validation rules, CRD changes, converters), security considerations, testing strategy, and implementation plan. Status: Draft.
    • RFC-0052 (multi-upstream IDP support) — referenced by RFC-0054 as a prerequisite; defines identity.UpstreamTokens map[string]string populated by auth middleware after TH-JWT validation.
    • RFC-0053 (embedded AS in vMCP) — referenced by RFC-0054 as a prerequisite; wires the embedded authorization server into vMCP so upstream tokens are acquired during the OAuth flow. Declares validation rules V-01 through V-07 and scaffolds validateAuthServerIntegration. Proposed docs at /Users/trey/Documents/GitHub/toolhive/docs/proposals/THV-0053-vmcp-embedded-authserver.md.

    Clarifying Questions & Answers

    Issue Style

    • Format: task-based engineering tickets
    • Rationale: Each phase is a discrete engineering deliverable with clear file-level targets and acceptance criteria; task-based framing matches the engineering workflow.

    Repository & Project

    Scope & Boundaries

    • Expected Outcome: The upstream_inject outgoing auth strategy is fully implemented, tested, and wired end-to-end — from the Go types layer through the Kubernetes CRD converter — enabling vMCP operators to configure backends that receive upstream IDP access tokens as Bearer authorization headers on outgoing requests.
    • In Scope:
      • Add StrategyTypeUpstreamInject constant, UpstreamInjectConfig struct, UpstreamInject field on BackendAuthStrategy, and ErrUpstreamTokenNotFound sentinel to pkg/vmcp/auth/types/types.go
      • Add SubjectProviderName field to TokenExchangeConfig in pkg/vmcp/auth/types/types.go
      • Regenerate zz_generated.deepcopy.go
      • Implement UpstreamInjectStrategy in pkg/vmcp/auth/strategies/upstream_inject.go
      • Update TokenExchangeStrategy.Authenticate() and internal tokenExchangeConfig for SubjectProviderName in pkg/vmcp/auth/strategies/tokenexchange.go
      • Register upstream_inject in pkg/vmcp/auth/factory/outgoing.go
      • Implement startup validation rules V-01, V-02, V-06 in pkg/vmcp/config/validator.go
      • Add ExternalAuthTypeUpstreamInject, UpstreamInjectSpec, and CRD validation to cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
      • Add SubjectProviderName to the CRD's TokenExchangeConfig struct
      • Implement UpstreamInjectConverter in pkg/vmcp/auth/converters/upstream_inject.go
      • Update TokenExchangeConverter.ConvertToStrategy() to populate SubjectProviderName
      • Register UpstreamInjectConverter in NewRegistry()
      • Unit tests for all new and modified code (table-driven, as specified in RFC §Testing Strategy)
    • Out of Scope:
      • Step-up auth signaling mechanics (UC-06) — ErrUpstreamTokenNotFound sentinel is defined here but the intercept/redirect flow is a separate RFC
      • Actor token (delegation) in token exchange — deferred
      • Token refresh / re-authorization — expired tokens are injected as-is; transparent refresh is deferred
      • New end-to-end / integration tests beyond those already specified in RFC-0053 (the RFC notes no new integration tests are required)
      • Architecture documentation updates (docs/arch/02-core-concepts.md, docs/vmcp-auth.md) — these are documentation tasks and not included in the 4 phase issues
    • Type: enhancement (additive new auth strategy within the existing vMCP auth framework)

    Technical Context

    • Affected Components:
      • pkg/vmcp/auth/types/ — type definitions and sentinel error
      • pkg/vmcp/auth/strategies/ — upstream_inject.go (new), tokenexchange.go (modified)
      • pkg/vmcp/auth/factory/ — outgoing auth registry registration
      • pkg/vmcp/config/ — startup validation rules V-01, V-02, V-06
      • cmd/thv-operator/api/v1alpha1/ — CRD types (mcpexternalauthconfig_types.go)
      • pkg/vmcp/auth/converters/ — upstream_inject.go (new), tokenexchange.go (modified)
      • zz_generated.deepcopy.go — regenerated after type changes in Phase 1
    • Known Constraints:
      • upstream_inject is Bearer-only; non-Bearer formats use header_injection
      • The strategy is stateless — no interface injection, no storage calls at request time; all state comes from identity.UpstreamTokens in context
      • No token values must appear in logs or error messages at any level
      • Phases are ordered by dependency: Phase 1 types must land before Phase 2 strategy, Phase 2 before Phase 3 validation (which references types), Phase 4 CRD can proceed after Phase 1 types but references strategy types
      • RFC-0052 and RFC-0053 must be merged before this RFC's implementation can be tested end-to-end
      • Uses go.uber.org/mock (gomock) for any mocks; mock files go in mocks/ subdirectories
      • All Go files need SPDX headers (// SPDX-FileCopyrightText: Copyright 2025 Stacklok, Inc. / // SPDX-License-Identifier: Apache-2.0)
      • +kubebuilder:object:generate=true and +gendoc markers required on new types for codegen
    • Target Milestone: None specified

    Dependencies & Integration

    • Depends On:
      • RFC-0052 (multi-upstream IDP support): Required for identity.UpstreamTokens to be defined and populated
      • RFC-0053 (embedded AS in vMCP): Required for the AS to be wired into vMCP so identity.UpstreamTokens is populated at request time; also defines cfg.AuthServer.RunConfig referenced in V-01/V-02 validation
    • Downstream Consumers:
      • UC-06 (step-up auth signaling) — will use errors.Is(err, ErrUpstreamTokenNotFound) to trigger step-up flows; defined in a future RFC
      • vMCP operators configuring backends that require upstream IDP tokens (GitHub, Atlassian, corporate SSO)
    • External Integrations:
      • RFC 8693 (OAuth 2.0 Token Exchange) — existing token_exchange strategy; SubjectProviderName enhancement uses upstream tokens as the RFC 8693 subject

    Acceptance & Verification

    • Success Criteria:
      • upstream_inject strategy correctly reads identity.UpstreamTokens[providerName] and injects as Authorization: Bearer on outgoing requests
      • ErrUpstreamTokenNotFound returned (and wrappable via errors.Is()) when the token is absent or empty
      • token_exchange with SubjectProviderName uses the upstream token as RFC 8693 subject instead of identity.Token
      • Startup validation V-01, V-02, V-06 reject misconfigured deployments with clear error messages
      • CRD supports type: upstreamInject with UpstreamInjectSpec.providerName; MCPExternalAuthConfig TokenExchangeConfig CRD struct exposes subjectProviderName
      • All unit tests pass; table-driven tests cover happy path, error cases, and edge cases per RFC §Testing Strategy
      • No token values appear in any log output or error messages
    • Test Scenarios: See RFC §Testing Strategy for the full table-driven test specification per file:
      • upstream_inject_test.go: 9 cases (happy path, token not found, empty token, health check bypass, nil strategy/config, Validate cases)
      • tokenexchange_test.go: 3 additions (SubjectProviderName used, SubjectProviderName missing provider, regression for existing behavior)
      • validator_test.go: 4 additions (V-01 negative, V-02 negative, V-06 negative, positive)
      • upstream_inject_converter_test.go: 3 cases (ConvertToStrategy valid/nil, ResolveSecrets pass-through)
    • Stakeholders: tgrunnagle (RFC author), jhrozek (epic issue author)

    Dry Run Mode

    • Enabled: false

    Issue Labels

    authentication, authorization, enhancement, go, vmcp

    Phase Issue Definitions

    Phase 1: Core types and sentinel (no behavior change)

    Files changed:

    • pkg/vmcp/auth/types/types.go — add StrategyTypeUpstreamInject constant, UpstreamInjectConfig struct, UpstreamInject *UpstreamInjectConfig field on BackendAuthStrategy, ErrUpstreamTokenNotFound sentinel, SubjectProviderName string field on TokenExchangeConfig
    • zz_generated.deepcopy.go — regenerate after type additions (task gen)

    Acceptance criteria:

    • New constant, structs, sentinel, and field are present and compile
    • zz_generated.deepcopy.go is regenerated and consistent with the new types
    • No runtime behavior changes — new fields are optional and unused
    • All existing tests continue to pass

    Phase 2: Strategy implementations

    Files changed:

    • pkg/vmcp/auth/strategies/upstream_inject.go — new file implementing UpstreamInjectStrategy (stateless, Bearer-only, ErrUpstreamTokenNotFound propagation, health check bypass, Validate())
    • pkg/vmcp/auth/strategies/tokenexchange.go — update Authenticate() and internal tokenExchangeConfig struct for SubjectProviderName
    • pkg/vmcp/auth/factory/outgoing.go — register StrategyTypeUpstreamInject / NewUpstreamInjectStrategy()
    • pkg/vmcp/auth/strategies/upstream_inject_test.go — new test file, 9 table-driven cases
    • pkg/vmcp/auth/strategies/tokenexchange_test.go — 3 new table entries

    Acceptance criteria:

    • UpstreamInjectStrategy.Authenticate() sets Authorization: Bearer <token> when token found in identity.UpstreamTokens
    • Returns ErrUpstreamTokenNotFound (wrapped with %w) when provider absent or token empty
    • Health check contexts return nil with no header set
    • TokenExchangeStrategy.Authenticate() uses identity.UpstreamTokens[SubjectProviderName] as subject when SubjectProviderName is set; falls back to identity.Token when unset (no regression)
    • upstream_inject registered in outgoing auth registry
    • All unit tests pass

    Phase 3: Startup validation

    Files changed:

    • pkg/vmcp/config/validator.go — add upstream_inject case to validateAuthServerIntegration implementing V-01 (no AS configured), V-02 (providerName not in AS upstream list), V-06 (empty providerName)
    • pkg/vmcp/config/validator_test.go — 4 new table-driven entries (V-01 negative, V-02 negative, V-06 negative, positive case)

    Acceptance criteria:

    • V-01: Error returned if upstream_inject backend configured but AuthServer == nil; error message references "no authServer configured"
    • V-02: Error returned if providerName is not in the AS upstream list; error message references the unknown provider name
    • V-06: Error returned if providerName is empty; error message references "non-empty providerName"
    • Positive case: upstream_inject backend with valid AS and matching provider returns nil
    • All unit tests pass

    Phase 4: CRD and converter

    Files changed:

    • cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go — add ExternalAuthTypeUpstreamInject constant, UpstreamInjectSpec struct, UpstreamInject *UpstreamInjectSpec field on MCPExternalAuthConfigSpec, CRD validation (spec/type equivalence check, per-type validation for non-empty providerName); add SubjectProviderName string to the CRD's TokenExchangeConfig struct
    • pkg/vmcp/auth/converters/upstream_inject.go — new file implementing UpstreamInjectConverter (stateless, no secrets, ConvertToStrategy, ResolveSecrets pass-through)
    • pkg/vmcp/auth/converters/tokenexchange.go (or equivalent converter file) — update ConvertToStrategy() to populate SubjectProviderName
    • Converter registry NewRegistry() — register UpstreamInjectConverter
    • pkg/vmcp/auth/converters/upstream_inject_test.go — new test file, 3 cases
    • pkg/vmcp/auth/converters/tokenexchange_test.go — regression tests for updated TokenExchangeConverter

    Acceptance criteria:

    • MCPExternalAuthConfig CRD accepts type: upstreamInject with upstreamInject.providerName
    • CRD admission rejects missing/mismatched upstreamInject spec relative to type
    • UpstreamInjectConverter.ConvertToStrategy() produces BackendAuthStrategy{Type: "upstream_inject", UpstreamInject: {ProviderName: ...}}
    • UpstreamInjectConverter.ResolveSecrets() returns the strategy unchanged
    • TokenExchangeConverter.ConvertToStrategy() populates SubjectProviderName from the CRD field
    • All unit tests pass

    Additional Notes

    • All 4 phases should be created as sub-issues of epic vMCP: implement upstream_inject outgoing auth strategy #3925 in stacklok/toolhive.
    • Phases should be implemented in order (1 → 2 → 3 → 4) due to type dependencies; Phase 4 can be parallelized with Phases 2 and 3 after Phase 1 lands since it only depends on Phase 1 types.
    • The RFC is in "Draft / Under Review" status as of 2026-03-10; implementation issues should reference the RFC document and the related stacklok-epics issue (chore(deps): Bump peter-evans/create-pull-request from 6 to 7 #251).
    • Token values must never appear in logs, error messages, or MCP protocol responses at any level — this is a hard security requirement enforced throughout all phases.
  6. tgrunnagle commented on Mar 13, 2026

    @tgrunnagle
    Collaborator

    Research: vMCP Upstream Inject Outgoing Auth Strategy (RFC-0054)

    Overview

    This document captures existing architectural context, coding standards, and design documentation
    relevant to the RFC-0054 implementation epic. It is intended for use by downstream planning agents
    to produce well-grounded phase issues.


    Local Repository Clones

    Repository Local Path Description
    stacklok/toolhive /Users/trey/Documents/GitHub/toolhive Primary repository — all source code affected by this RFC

    Organizational Coding Standards

    Sources: CLAUDE.md, CONTRIBUTING.md, docs/cli-best-practices.md

    SPDX License Headers

    All Go files must have SPDX headers at the top:

    // SPDX-FileCopyrightText: Copyright 2025 Stacklok, Inc.
    // SPDX-License-Identifier: Apache-2.0

    Use task license-check to verify; task license-fix to add automatically. CI enforces this on
    all PRs (ignores generated files: mocks, testdata, vendor, *.pb.go, zz_generated*.go).

    Commit and PR Style

    • No "Conventional Commits" prefixes (no feat:, fix:, chore:, etc.)
    • Subject line: imperative mood, capitalized, under 50 characters, no trailing period
    • PR titles: under 70 characters, same rules as commit subjects
    • PRs over 400 lines of logic code or 10 non-generated files should be split
    • All PRs must follow .github/pull_request_template.md (Summary / Type of change / Test plan)

    Codegen Markers on New Types

    New structs that participate in deep-copy generation (typically those in pkg/vmcp/auth/types/
    and operator API types) need both:

    // +kubebuilder:object:generate=true
    // +gendoc

    After adding or modifying types in pkg/vmcp/auth/types/, run:

    task gen

    This regenerates pkg/vmcp/auth/types/zz_generated.deepcopy.go.

    After modifying CRD types in cmd/thv-operator/api/v1alpha1/, run:

    task operator-generate
    task operator-manifests
    # inside cmd/thv-operator/:
    task crdref-gen

    Testing Requirements

    • Unit tests live alongside source files (*_test.go)
    • Prefer table-driven (declarative) tests over imperative tests
    • Use go.uber.org/mock (gomock) for mocks; mock files go in mocks/ subdirectories; generate
      with mockgen
    • Use require.NoError(t, err) (from github.com/stretchr/testify) rather than t.Fatal
    • Tests that touch on-disk state must write to isolated t.TempDir() paths; on macOS, resolve
      symlinks with filepath.EvalSymlinks(dir) when validators reject symlinked paths
    • Prefer very large port numbers (near math.MaxInt16) in tests to avoid port conflicts
    • No sensitive data (tokens, credentials) in log output or error messages at any level
    • E2E tests are the primary CLI testing strategy; unit tests focus on pkg/ business logic

    Go Coding Style

    • Public methods in the top half of a file; private methods in the bottom half
    • Prefer immutable variable assignment via immediately-invoked anonymous functions over
      mutation across multiple if branches
    • Use fmt.Errorf with %w to preserve error chains; use errors.Is() / errors.As() for
      error inspection

    Existing Architecture Documentation

    vMCP Auth Architecture

    Strategy Interface

    Defined in pkg/vmcp/auth/auth.go:

    type Strategy interface {
        Name() string
        Authenticate(ctx context.Context, req *http.Request, strategy *authtypes.BackendAuthStrategy) error
        Validate(strategy *authtypes.BackendAuthStrategy) error
    }

    DefaultOutgoingAuthRegistry (in pkg/vmcp/auth/outgoing_registry.go) enforces that
    RegisterStrategy(name, strategy) requires name == strategy.Name(), ensuring all registered
    strategies are self-describing.

    Existing Strategy Constants and Types

    File: pkg/vmcp/auth/types/types.go

    Current strategy type constants:

    const (
        StrategyTypeUnauthenticated = "unauthenticated"
        StrategyTypeHeaderInjection = "header_injection"
        StrategyTypeTokenExchange   = "token_exchange"
    )

    BackendAuthStrategy is the union-discriminated config struct:

    // +kubebuilder:object:generate=true
    // +gendoc
    type BackendAuthStrategy struct {
        Type            string                `json:"type" yaml:"type"`
        HeaderInjection *HeaderInjectionConfig `json:"headerInjection,omitempty" yaml:"headerInjection,omitempty"`
        TokenExchange   *TokenExchangeConfig   `json:"tokenExchange,omitempty" yaml:"tokenExchange,omitempty"`
    }

    TokenExchangeConfig (abridged):

    type TokenExchangeConfig struct {
        TokenURL         string   `json:"tokenUrl" yaml:"tokenUrl"`
        ClientID         string   `json:"clientId,omitempty" yaml:"clientId,omitempty"`
        ClientSecret     string   `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"`
        ClientSecretEnv  string   `json:"clientSecretEnv,omitempty" yaml:"clientSecretEnv,omitempty"`
        Audience         string   `json:"audience,omitempty" yaml:"audience,omitempty"`
        Scopes           []string `json:"scopes,omitempty" yaml:"scopes,omitempty"`
        SubjectTokenType string   `json:"subjectTokenType,omitempty" yaml:"subjectTokenType,omitempty"`
        // SubjectProviderName to be added by Phase 1 of this RFC
    }

    zz_generated.deepcopy.go (also in pkg/vmcp/auth/types/) currently covers BackendAuthStrategy,
    HeaderInjectionConfig, and TokenExchangeConfig. After Phase 1 adds UpstreamInjectConfig,
    task gen must be re-run to regenerate this file.

    Existing Strategy Implementations

    All strategies are in pkg/vmcp/auth/strategies/:

    • unauthenticated.go — no-op, always returns nil; health check: always passes
    • header_injection.go — injects static header from BackendAuthStrategy.HeaderInjection; applies
      to all requests including health checks; validates with CRLF-injection prevention
    • tokenexchange.go — RFC 8693 token exchange; caches ExchangeConfig per backend config (not
      per user); health check path uses client credentials grant if ClientID/ClientSecret are set,
      otherwise skips auth; uses auth.IdentityFromContext(ctx) to obtain identity.Token

    The new upstream_inject.go strategy (Phase 2) will mirror unauthenticated.go in
    structurally stateless design but read from identity.UpstreamTokens[providerName].

    Factory Registration

    File: pkg/vmcp/auth/factory/outgoing.go

    func NewOutgoingAuthRegistry(
        _ context.Context,
        envReader env.Reader,
    ) (auth.OutgoingAuthRegistry, error) {
        registry := auth.NewDefaultOutgoingAuthRegistry()
        // Registers: unauthenticated, header_injection, token_exchange
        ...
        return registry, nil
    }

    Phase 2 adds one more registry.RegisterStrategy(authtypes.StrategyTypeUpstreamInject, strategies.NewUpstreamInjectStrategy()) call here. No signature changes.

    Startup Validator

    File: pkg/vmcp/config/validator.go

    DefaultValidator.Validate(cfg *Config) orchestrates all validation. The method
    validateBackendAuthStrategy currently validates token_exchange and header_injection type-
    specific requirements and lists allowed strategy types:

    validTypes := []string{
        authtypes.StrategyTypeUnauthenticated,
        authtypes.StrategyTypeHeaderInjection,
        authtypes.StrategyTypeTokenExchange,
        // TODO: Add more as strategies are implemented
    }

    Phase 3 of this RFC adds authtypes.StrategyTypeUpstreamInject to this list and implements V-01,
    V-02, and V-06 in a new validateAuthServerIntegration case. The validator is called at process
    startup (YAML path) and by the operator reconciler (Kubernetes path).

    CRD Auth Types

    File: cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go

    Current ExternalAuthType constants:

    const (
        ExternalAuthTypeTokenExchange      ExternalAuthType = "tokenExchange"
        ExternalAuthTypeHeaderInjection    ExternalAuthType = "headerInjection"
        ExternalAuthTypeBearerToken        ExternalAuthType = "bearerToken"
        ExternalAuthTypeUnauthenticated    ExternalAuthType = "unauthenticated"
        ExternalAuthTypeEmbeddedAuthServer ExternalAuthType = "embeddedAuthServer"
        ExternalAuthTypeAWSSts             ExternalAuthType = "awsSts"
    )

    MCPExternalAuthConfigSpec holds optional typed spec fields for each auth type (one field per
    type, keyed by Type). Phase 4 adds ExternalAuthTypeUpstreamInject and UpstreamInject *UpstreamInjectSpec.

    The CEL admission rules use the pattern:

    self.type == 'X' ? has(self.x) : !has(self.x)
    

    Phase 4 adds a matching CEL rule for upstreamInject. The Go Validate() method on
    MCPExternalAuthConfig mirrors this with a nil-equality check:

    if (r.Spec.UpstreamInject == nil) == (r.Spec.Type == ExternalAuthTypeUpstreamInject) {
        return fmt.Errorf("upstreamInject must be set when and only when type is upstreamInject")
    }

    The CRD's TokenExchangeConfig struct (distinct from pkg/vmcp/auth/types/TokenExchangeConfig)
    also needs SubjectProviderName string added in Phase 4.

    Converter Registry

    File: pkg/vmcp/auth/converters/interface.go

    StrategyConverter interface:

    type StrategyConverter interface {
        StrategyType() string
        ConvertToStrategy(externalAuth *mcpv1alpha1.MCPExternalAuthConfig) (*authtypes.BackendAuthStrategy, error)
        ResolveSecrets(ctx context.Context, externalAuth *mcpv1alpha1.MCPExternalAuthConfig,
            k8sClient client.Client, namespace string,
            strategy *authtypes.BackendAuthStrategy) (*authtypes.BackendAuthStrategy, error)
    }

    NewRegistry() currently registers:

    r.Register(mcpv1alpha1.ExternalAuthTypeTokenExchange, &TokenExchangeConverter{})
    r.Register(mcpv1alpha1.ExternalAuthTypeHeaderInjection, &HeaderInjectionConverter{})
    r.Register(mcpv1alpha1.ExternalAuthTypeUnauthenticated, &UnauthenticatedConverter{})

    Phase 4 adds r.Register(mcpv1alpha1.ExternalAuthTypeUpstreamInject, &UpstreamInjectConverter{}).

    The TokenExchangeConverter.ConvertToStrategy() currently does not populate SubjectProviderName
    because that field does not exist yet in either the CRD or the types package. Phase 4 updates it
    to pass tokenExchange.SubjectProviderName through.

    Identity and UpstreamTokens (RFC-0052 Prerequisite)

    File: pkg/auth/identity.go

    Identity is the primary authenticated-principal struct. As of the current codebase, it has:

    type Identity struct {
        Subject   string
        Name      string
        Email     string
        Groups    []string
        Claims    map[string]any
        Token     string       // original auth token (redacted in logs/JSON)
        TokenType string
        Metadata  map[string]string
    }

    RFC-0052 will add UpstreamTokens map[string]string to this struct (keyed by upstream provider
    name, populated by the auth middleware from GetAllUpstreamTokens(tsid) in session storage). This
    field is the direct dependency of UpstreamInjectStrategy.Authenticate(). Until RFC-0052 merges,
    the strategy cannot be tested end-to-end but the types and factory wiring can be implemented.

    auth.IdentityFromContext(ctx) is defined in pkg/auth/context.go and is already used by
    TokenExchangeStrategy — UpstreamInjectStrategy will use the same pattern.

    Health Check Detection

    File: pkg/vmcp/health/monitor.go

    func IsHealthCheck(ctx context.Context) bool { ... }

    All strategies call health.IsHealthCheck(ctx) at the top of Authenticate() to bypass
    per-user auth for health probes. UpstreamInjectStrategy returns nil on health check (no
    header set), consistent with all other strategies.


    Design Documentation

    RFC-0054 (Primary RFC for this Epic)

    Location: docs/proposals/THV-0054-vmcp-upstream-inject-strategy.md

    Status: Draft (2026-03-10). Contains the complete design including:

    • Flowchart of the per-request Mode B flow
    • Type additions to pkg/vmcp/auth/types/types.go
    • Full implementation of UpstreamInjectStrategy including health check bypass and error wrapping
    • Enhanced TokenExchangeStrategy.Authenticate() for SubjectProviderName
    • Factory changes to pkg/vmcp/auth/factory/outgoing.go
    • V-01, V-02, V-06 startup validation rules with exact error message text
    • CRD changes to cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
    • UpstreamInjectConverter implementation
    • Full test case table per file
    • Security considerations (no token in error messages or logs, operator-controlled provider name)
    • Compatibility analysis (all changes are additive)

    RFC-0052 (Prerequisite — Multi-Upstream IDP Support)

    Location: docs/proposals/THV-0052-multi-upstream-idp-authserver.md

    Status: Draft (2026-03-09). Defines:

    • Identity.UpstreamTokens map[string]string — the field RFC-0054 reads at request time
    • GetAllUpstreamTokens(sessionID) bulk-read on UpstreamTokenStorage
    • Auth middleware enrichment of Identity.UpstreamTokens from session storage after TH-JWT validation
    • Backward compatibility with single-upstream deployments

    RFC-0054 Phase 1 can be implemented while RFC-0052 is pending (type additions are independent).
    Phase 2 will compile but cannot be fully tested end-to-end until RFC-0052 merges and
    identity.UpstreamTokens is populated in the middleware.

    RFC-0053 (Prerequisite — Embedded AS in vMCP)

    Location: docs/proposals/THV-0053-vmcp-embedded-authserver.md

    Status: Draft (2026-03-10). Defines:

    • Wiring the embedded auth server into the vMCP flow (Mode B)
    • Validation rules V-01 through V-07 and the validateAuthServerIntegration scaffold in
      pkg/vmcp/config/validator.go — RFC-0054 Phase 3 fills in the upstream_inject case
    • cfg.AuthServer.RunConfig field (referenced by V-01/V-02 validation)
    • Phase 3 of RFC-0053 (#4142) creates validateAuthServerIntegration that RFC-0054 Phase 3 adds to

    Key Code Pointers by Phase

    Phase 1 — Core Types and Sentinel

    Change File
    Add StrategyTypeUpstreamInject = "upstream_inject" constant pkg/vmcp/auth/types/types.go
    Add UpstreamInjectConfig struct (with ProviderName string) pkg/vmcp/auth/types/types.go
    Add UpstreamInject *UpstreamInjectConfig field to BackendAuthStrategy pkg/vmcp/auth/types/types.go
    Add ErrUpstreamTokenNotFound = errors.New(...) sentinel var pkg/vmcp/auth/types/types.go
    Add SubjectProviderName string field to TokenExchangeConfig pkg/vmcp/auth/types/types.go
    Regenerate deep-copy functions pkg/vmcp/auth/types/zz_generated.deepcopy.go

    New struct needs // +kubebuilder:object:generate=true and // +gendoc markers.

    zz_generated.deepcopy.go currently covers BackendAuthStrategy, HeaderInjectionConfig, and
    TokenExchangeConfig. After adding UpstreamInjectConfig (which only has scalar fields, so its
    DeepCopyInto will be a trivial *out = *in), and the UpstreamInject *UpstreamInjectConfig
    pointer field on BackendAuthStrategy, the generated file will also include UpstreamInjectConfig
    deep-copy functions and a nil-check pointer copy for the new field.

    Phase 2 — Strategy Implementations

    Change File
    New UpstreamInjectStrategy struct implementing auth.Strategy pkg/vmcp/auth/strategies/upstream_inject.go (new)
    Update TokenExchangeStrategy.Authenticate() and tokenExchangeConfig for SubjectProviderName pkg/vmcp/auth/strategies/tokenexchange.go
    Register StrategyTypeUpstreamInject in outgoing auth registry pkg/vmcp/auth/factory/outgoing.go
    Unit tests (9 cases) pkg/vmcp/auth/strategies/upstream_inject_test.go (new)
    Unit tests (3 additions) pkg/vmcp/auth/strategies/tokenexchange_test.go

    Key implementation note for UpstreamInjectStrategy.Authenticate():

    • Use health.IsHealthCheck(ctx) from pkg/vmcp/health/monitor.go at the top
    • Use auth.IdentityFromContext(ctx) from pkg/auth/context.go to get the identity
    • Read identity.UpstreamTokens[providerName] — both missing key and empty value → ErrUpstreamTokenNotFound
    • Wrap with fmt.Errorf("upstream_inject provider %q: %w", providerName, authtypes.ErrUpstreamTokenNotFound)
    • Set req.Header.Set("Authorization", "Bearer "+token) on success
    • Never include the token value in any error message or log

    TokenExchangeStrategy changes: the internal tokenExchangeConfig struct gains SubjectProviderName string.
    In parseTokenExchangeConfig, populate it from strategy.TokenExchange.SubjectProviderName.
    In Authenticate(), resolve subjectToken from identity.UpstreamTokens[config.SubjectProviderName]
    when SubjectProviderName != "", then pass subjectToken to createUserConfig. buildCacheKey
    does NOT include SubjectProviderName (the server-level cache template is subject-agnostic).

    Phase 3 — Startup Validation

    Change File
    Add upstream_inject case to validateAuthServerIntegration (V-01, V-02, V-06) pkg/vmcp/config/validator.go
    Add StrategyTypeUpstreamInject to the validTypes slice in validateBackendAuthStrategy pkg/vmcp/config/validator.go
    4 new table-driven test entries pkg/vmcp/config/validator_test.go

    Validation rules:

    • V-01: upstream_inject backend present but cfg.AuthServer == nil → error referencing "no authServer configured"
    • V-02: strategy.UpstreamInject.ProviderName not in AS upstream provider list → error referencing the unknown provider name
    • V-06: strategy.UpstreamInject.ProviderName == "" → error referencing "non-empty providerName"

    RFC-0053 Phase 3 (#4142) scaffolds validateAuthServerIntegration; RFC-0054 Phase 3 adds the
    upstream_inject case to that function's switch statement.

    Phase 4 — CRD and Converter

    Change File
    Add ExternalAuthTypeUpstreamInject ExternalAuthType = "upstreamInject" constant cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
    Add UpstreamInjectSpec struct with ProviderName string cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
    Add UpstreamInject *UpstreamInjectSpec field to MCPExternalAuthConfigSpec cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
    Add CEL admission rule for upstreamInject type equivalence cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
    Add upstreamInject to +kubebuilder:validation:Enum on Type field cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
    Add per-type validation for non-empty providerName to Validate() cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
    Add SubjectProviderName string to CRD TokenExchangeConfig struct cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go
    New UpstreamInjectConverter (stateless, no secrets) pkg/vmcp/auth/converters/upstream_inject.go (new)
    Update TokenExchangeConverter.ConvertToStrategy() to populate SubjectProviderName pkg/vmcp/auth/converters/token_exchange.go
    Register UpstreamInjectConverter in NewRegistry() pkg/vmcp/auth/converters/interface.go
    Unit tests (3 cases) pkg/vmcp/auth/converters/upstream_inject_test.go (new)
    Regression tests for updated TokenExchangeConverter pkg/vmcp/auth/converters/token_exchange_test.go

    After CRD type changes run operator codegen:

    task operator-generate
    task operator-manifests
    # inside cmd/thv-operator/:
    task crdref-gen

    Key Conventions to Follow

    Error Wrapping Pattern

    All strategies wrap sentinel errors with %w for errors.Is() compatibility:

    // Correct — errors.Is(err, ErrUpstreamTokenNotFound) works at any depth
    return fmt.Errorf("upstream_inject provider %q: %w", providerName, authtypes.ErrUpstreamTokenNotFound)

    Health Check Pattern

    Every Authenticate() implementation begins with a health check guard:

    if health.IsHealthCheck(ctx) {
        return nil
    }

    UpstreamInjectStrategy returns nil with no header set (no upstream token at probe time).

    No Token Values in Output

    Hard security requirement throughout all phases:

    • Error messages: include provider name only, never the token value
    • Logs: WARN-level for ErrUpstreamTokenNotFound (provider name and backend name only)
    • Startup validation errors: include backend name and provider name only

    Strategy Self-Registration Pattern

    DefaultOutgoingAuthRegistry.RegisterStrategy(name, strategy) enforces name == strategy.Name().
    New strategies must return their constant from Name():

    func (*UpstreamInjectStrategy) Name() string {
        return authtypes.StrategyTypeUpstreamInject
    }

    Type Discriminated Structs Pattern

    BackendAuthStrategy follows a discriminated union pattern: the Type string selects which
    optional config pointer is populated. Startup validation and strategy Validate() check that the
    expected pointer is non-nil. CRD CEL rules enforce spec/type equivalence at admission time.


    Issue Style Guidelines

    Based on the intake document and review of existing issues:

    • Title format: Phase N: <short imperative description> (RFC-0054)
    • Description: one paragraph summary of the phase's purpose
    • Context section: references to RFC-0054 sections and related code files
    • Acceptance criteria: bulleted checkbox list of specific, verifiable outcomes
    • Technical approach: concrete code pointers (file paths, function names, type names)
    • Out of scope: explicit boundaries to prevent scope creep
    • References: links to RFC, parent epic, related issues
    • Labels: authentication, authorization, enhancement, go, vmcp
    • Parent epic: vMCP: implement upstream_inject outgoing auth strategy #3925 (all 4 phase issues are sub-issues)
    • Dry run: false (issues will be created)

    Dependency Order

    Phase 1 (types) → Phase 2 (strategies) → Phase 3 (validation)
    Phase 1 (types) → Phase 4 (CRD + converter) [can parallelize with Phases 2 and 3]
    
    RFC-0052 (identity.UpstreamTokens) ─┐
                                         ├─ required for full end-to-end test of Phase 2
    RFC-0053 Phase 3 (#4142) ────────────┘ required for Phase 3 (validateAuthServerIntegration scaffold)
    

    Phase 4 can proceed immediately after Phase 1 lands, since it only depends on the types package.
    It does not require RFC-0052 or RFC-0053 to compile or unit-test.


    Gaps and Notes

    • identity.UpstreamTokens does not yet exist in pkg/auth/identity.go — it is added by RFC-0052.
      Phase 1 and Phase 4 can be implemented and unit-tested without it; Phase 2 unit tests can
      populate a mock identity struct directly once the field exists.
    • validateAuthServerIntegration does not yet exist in pkg/vmcp/config/validator.go — it is
      scaffolded by RFC-0053 Phase 3. Phase 3 of this RFC adds the upstream_inject case to it.
    • No new integration or E2E tests are required by this RFC; the full flow E2E is covered by
      RFC-0053's test specification.
    • Architecture documentation updates (docs/arch/02-core-concepts.md, docs/vmcp-auth.md) are
      explicitly out of scope per the intake document and should not be included in phase issues.
  7. tgrunnagle commented on Mar 13, 2026

    @tgrunnagle
    Collaborator

    Architecture: vMCP Upstream Inject Outgoing Auth Strategy (RFC-0054)

    Overview

    This epic adds the upstream_inject outgoing auth strategy to vMCP. The strategy reads a named
    upstream provider's access token from identity.UpstreamTokens (populated by RFC-0052's auth
    middleware) and injects it as Authorization: Bearer on outgoing backend requests. It also adds
    an optional subjectProviderName field to token_exchange for RFC 8693 subject resolution from
    upstream tokens. Implementation spans four ordered phases: types, strategy, validation, CRD/converter.

    Code Structure

    New Files

    • pkg/vmcp/auth/strategies/upstream_inject.go — UpstreamInjectStrategy implementation (Phase 2)
    • pkg/vmcp/auth/strategies/upstream_inject_test.go — 9 table-driven test cases (Phase 2)
    • pkg/vmcp/auth/converters/upstream_inject.go — UpstreamInjectConverter implementation (Phase 4)
    • pkg/vmcp/auth/converters/upstream_inject_test.go — 3 test cases (Phase 4)

    Modified Files

    • pkg/vmcp/auth/types/types.go — add constant, struct, sentinel, two fields (Phase 1)
    • pkg/vmcp/auth/types/zz_generated.deepcopy.go — regenerated via task gen (Phase 1)
    • pkg/vmcp/auth/strategies/tokenexchange.go — add SubjectProviderName path to Authenticate() and tokenExchangeConfig (Phase 2)
    • pkg/vmcp/auth/strategies/tokenexchange_test.go — 3 new table entries (Phase 2)
    • pkg/vmcp/auth/factory/outgoing.go — register upstream_inject strategy (Phase 2)
    • pkg/vmcp/config/validator.go — add upstream_inject to validTypes, implement V-01/V-02/V-06 (Phase 3)
    • pkg/vmcp/config/validator_test.go — 4 new table entries (Phase 3)
    • cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go — new constant, struct, spec field, CEL rule, enum value, SubjectProviderName on CRD TokenExchangeConfig (Phase 4)
    • pkg/vmcp/auth/converters/token_exchange.go — populate SubjectProviderName in ConvertToStrategy() (Phase 4)
    • pkg/vmcp/auth/converters/token_exchange_test.go — regression entries (Phase 4)
    • pkg/vmcp/auth/converters/interface.go — register UpstreamInjectConverter in NewRegistry() (Phase 4)

    Reference Implementations

    • pkg/vmcp/auth/strategies/unauthenticated.go — structural model for the stateless strategy pattern
    • pkg/vmcp/auth/strategies/tokenexchange.go — model for how Authenticate() accesses identity via context
    • pkg/vmcp/auth/converters/token_exchange.go — model for ConvertToStrategy / ResolveSecrets pattern
    • cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go — model for CEL rules, type enum, validateTypeConfigConsistency pattern

    API Contracts

    Phase 1 Type Additions (pkg/vmcp/auth/types/types.go)

    All downstream phases depend on these types. They must land before Phases 2, 3, and 4.

    // New constant — added alongside existing StrategyType* constants
    const StrategyTypeUpstreamInject = "upstream_inject"
    
    // New sentinel — checked with errors.Is() by UC-06 (future RFC)
    var ErrUpstreamTokenNotFound = errors.New("upstream token not found")
    
    // New config struct — needs +kubebuilder:object:generate=true and +gendoc markers
    // +kubebuilder:object:generate=true
    // +gendoc
    type UpstreamInjectConfig struct {
        ProviderName string `json:"providerName" yaml:"providerName"`
    }
    
    // BackendAuthStrategy gains one field (existing fields unchanged)
    type BackendAuthStrategy struct {
        // ... existing fields ...
        UpstreamInject *UpstreamInjectConfig `json:"upstreamInject,omitempty" yaml:"upstreamInject,omitempty"`
    }
    
    // TokenExchangeConfig gains one optional field (all existing fields unchanged)
    type TokenExchangeConfig struct {
        // ... existing fields ...
        SubjectProviderName string `json:"subjectProviderName,omitempty" yaml:"subjectProviderName,omitempty"`
    }

    Phase 2 Strategy Interface (pkg/vmcp/auth)

    UpstreamInjectStrategy must satisfy the existing auth.Strategy interface:

    // Defined in pkg/vmcp/auth/auth.go — no changes
    type Strategy interface {
        Name() string
        Authenticate(ctx context.Context, req *http.Request, strategy *authtypes.BackendAuthStrategy) error
        Validate(strategy *authtypes.BackendAuthStrategy) error
    }

    Constructor signature for factory registration:

    func NewUpstreamInjectStrategy() *UpstreamInjectStrategy
    func (*UpstreamInjectStrategy) Name() string  // returns authtypes.StrategyTypeUpstreamInject

    DefaultOutgoingAuthRegistry.RegisterStrategy enforces name == strategy.Name(), so Name()
    must return exactly authtypes.StrategyTypeUpstreamInject.

    Phase 4 Converter Interface (pkg/vmcp/auth/converters/interface.go)

    UpstreamInjectConverter must satisfy the existing StrategyConverter interface (no changes):

    type StrategyConverter interface {
        StrategyType() string
        ConvertToStrategy(externalAuth *mcpv1alpha1.MCPExternalAuthConfig) (*authtypes.BackendAuthStrategy, error)
        ResolveSecrets(ctx context.Context, externalAuth *mcpv1alpha1.MCPExternalAuthConfig,
            k8sClient client.Client, namespace string,
            strategy *authtypes.BackendAuthStrategy) (*authtypes.BackendAuthStrategy, error)
    }

    UpstreamInjectConverter.ResolveSecrets is a no-op pass-through (no static secrets to resolve).

    Integration Points

    identity.UpstreamTokens (RFC-0052 prerequisite)

    • Current state: pkg/auth/identity.go — Identity struct does not yet have UpstreamTokens
    • After RFC-0052: Identity.UpstreamTokens map[string]string keyed by provider name
    • Usage: auth.IdentityFromContext(ctx) (from pkg/auth/context.go) retrieves the identity; strategy reads identity.UpstreamTokens[providerName]
    • Compile-time dependency: Phases 1 and 4 compile without RFC-0052; Phase 2 requires the field to exist

    validateAuthServerIntegration (RFC-0053 Phase 3 prerequisite)

    Health Check Bypass (pkg/vmcp/health/monitor.go)

    // Used at the top of every Authenticate() implementation
    if health.IsHealthCheck(ctx) {
        return nil  // upstream_inject returns nil with no header set
    }

    Outgoing Auth Factory (pkg/vmcp/auth/factory/outgoing.go)

    Unconditional registration — no signature changes to NewOutgoingAuthRegistry:

    if err := registry.RegisterStrategy(
        authtypes.StrategyTypeUpstreamInject,
        strategies.NewUpstreamInjectStrategy(),
    ); err != nil {
        return nil, err
    }

    CRD Converter Registry (pkg/vmcp/auth/converters/interface.go)

    One additional r.Register call in NewRegistry():

    r.Register(mcpv1alpha1.ExternalAuthTypeUpstreamInject, &UpstreamInjectConverter{})

    CRD Admission (cmd/thv-operator/api/v1alpha1/mcpexternalauthconfig_types.go)

    Two changes follow existing patterns:

    1. CEL rule added to the MCPExternalAuthConfigSpec kubebuilder markers:
      self.type == 'upstreamInject' ? has(self.upstreamInject) : !has(self.upstreamInject)
      
    2. validateTypeConfigConsistency() gains a nil-equality check mirroring all other types:
      if (r.Spec.UpstreamInject == nil) == (r.Spec.Type == ExternalAuthTypeUpstreamInject) {
          return fmt.Errorf("upstreamInject must be set when and only when type is upstreamInject")
      }
    3. upstreamInject added to +kubebuilder:validation:Enum on the Type field

    Phase Dependency Diagram

    graph TD
        P1["Phase 1: Types & sentinel<br/>(pkg/vmcp/auth/types/types.go)"]
        P2["Phase 2: Strategy impl<br/>(strategies/upstream_inject.go,<br/>factory/outgoing.go)"]
        P3["Phase 3: Startup validation<br/>(config/validator.go)"]
        P4["Phase 4: CRD & converter<br/>(v1alpha1 types,<br/>converters/upstream_inject.go)"]
        RFC052["RFC-0052<br/>identity.UpstreamTokens"]
        RFC053P3["RFC-0053 Phase 3 (#4142)<br/>validateAuthServerIntegration scaffold"]
    
        P1 --> P2
        P2 --> P3
        P1 --> P4
        RFC052 -.->|"required for full e2e test"| P2
        RFC053P3 -.->|"required for Phase 3"| P3
    
    Loading

    Phase 4 can be worked in parallel with Phases 2 and 3 once Phase 1 lands.

    Core Principles

    1. Stateless strategy: UpstreamInjectStrategy has no fields, no cache, no mutexes; all state comes from identity.UpstreamTokens in context (see pkg/vmcp/auth/strategies/unauthenticated.go as structural model)

    2. Error wrapping for sentinel propagation: Always wrap ErrUpstreamTokenNotFound with %w so errors.Is() works at any depth:

      return fmt.Errorf("upstream_inject provider %q: %w", providerName, authtypes.ErrUpstreamTokenNotFound)
    3. No token values in any output: Error messages, log lines, and validation errors include provider names and backend names only — never token values (hard security requirement for all phases)

    4. Health check guard first: Every Authenticate() begins with health.IsHealthCheck(ctx) check; upstream_inject returns nil with no header set on health probes

    5. Discriminated union pattern: BackendAuthStrategy.Type selects which config pointer is populated; Validate() and startup validation enforce the pointer is non-nil; CRD CEL rules enforce spec/type equivalence at admission time

    6. Additive-only changes: All changes are additive; no existing behavior is altered for configs without the new fields

    Constraints

    • Bearer-only: upstream_inject always injects Authorization: Bearer <token>; non-Bearer upstream token injection must use header_injection
    • Phase ordering: Phase 1 (types) must merge before Phase 2 (strategy) and Phase 4 (CRD/converter); Phase 3 requires RFC-0053 Phase 3 (Phase 3: Startup validation (V-01..V-07) — upstream_inject types and validateAuthServerIntegration #4142) to have created validateAuthServerIntegration
    • RFC-0052 dependency: identity.UpstreamTokens field does not exist until RFC-0052 merges; Phases 1 and 4 can proceed without it; Phase 2 compiles against the field and requires RFC-0052 to be merged first
    • Codegen after Phase 1: Run task gen after Phase 1 to regenerate pkg/vmcp/auth/types/zz_generated.deepcopy.go
    • Codegen after Phase 4 CRD changes: Run task operator-generate, task operator-manifests, and task crdref-gen (from cmd/thv-operator/) after Phase 4 CRD changes
    • SubjectProviderName not in buildCacheKey: The server-level ExchangeConfig cache in TokenExchangeStrategy is keyed on server config, not per-user subject; SubjectProviderName is resolved per-request in Authenticate() after the cache lookup
    • No new integration/E2E tests: Per intake, no new integration or E2E test files are required; full flow E2E is covered by RFC-0053's test specification

    Out of Scope

    • Step-up auth signaling mechanics (UC-06) — ErrUpstreamTokenNotFound sentinel is defined here but the intercept/redirect flow is a separate RFC
    • Actor token (delegation) in token exchange — deferred; ActorProviderName parallel field not in scope
    • Token expiry checking or transparent refresh in upstream_inject — expired tokens are injected as-is
    • Architecture documentation updates (docs/arch/02-core-concepts.md, docs/vmcp-auth.md) — explicitly out of scope per intake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

authenticationauthorizationenhancementgovmcp

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions