Skip to content

vMCP: Load authz config from ConfigMap (policies + primaryUpstreamProvider) #5208

@tgrunnagle

Description

@tgrunnagle

Background

pkg/vmcpconfig/converter.go has two TODOs covering the configMap-sourced authz path on VirtualMCPServer:

  • converter.go:192TODO: Load policies from ConfigMap if Type is "configMap"
  • converter.go:210TODO: load primaryUpstreamProvider from configMap

Today, both TODOs mean a VirtualMCPServer with spec.incomingAuth.authzConfig.type: configMap silently produces a vMCP runtime that has no Cedar middleware installed (the factory at pkg/vmcp/auth/factory/incoming.go:88 requires len(cfg.Authz.Policies) > 0). And there is no way for configMap users to override the auto-selected primary upstream provider, because that field lives on InlineAuthzConfig only.

Tasks

  • Extract a shared loader (e.g. in cmd/thv-operator/pkg/controllerutil/) that reads + parses the policy ConfigMap. The MCPServer/runner path (AddAuthzConfigOptions) and the vMCP converter should both call it. The loader should return policies + any primary-upstream-provider configuration.
  • Wire the converter: when Type == \"configMap\", call the loader, populate incoming.Authz.Policies (and PrimaryUpstreamProvider if applicable). Fail closed on missing/malformed/empty configMap.
  • Decide where primaryUpstreamProvider lives for configMap users:
    • Option A — parse it from the policy ConfigMap body (mirrors inline shape, but validator must read the configMap to validate).
    • Option B — lift PrimaryUpstreamProvider from InlineAuthzConfig to AuthzConfigRef so it lives on the spec and is source-agnostic. Validator stays simple. Recommended.
  • Status condition parity: add ConditionReasonAuthzConfigMapNotFound to virtualmcpserver_types.go (already exists on MCPRemoteProxy at mcpremoteproxy_types.go:336).
  • Update the validator: drop the inline-only assumption in AuthzConfigRef.ExplicitPrimaryUpstreamProvider() once the schema decision lands.
  • Tests: converter cases (success, missing CM, missing key, empty value, malformed YAML); validator case for configMap with explicit provider.

Discovered via

Acceptance criteria

  • A VirtualMCPServer with authzConfig.type: configMap and a valid policy ConfigMap deploys with Cedar middleware installed and policies enforced.
  • Bad/missing configMaps fail at admission with a clear status condition (parallel to MCPRemoteProxy).
  • ConfigMap users can pin a primary upstream provider via the schema decision above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    authorizationenhancementNew feature or requestgoPull requests that update go codekubernetesItems related to KubernetesoperatorvmcpVirtual MCP Server related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions