Wire embedded auth server into VirtualMCPServer converter and deployment#4383
Wire embedded auth server into VirtualMCPServer converter and deployment#4383
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4383 +/- ##
==========================================
- Coverage 69.49% 69.49% -0.01%
==========================================
Files 485 485
Lines 49841 49935 +94
==========================================
+ Hits 34638 34703 +65
- Misses 12528 12549 +21
- Partials 2675 2683 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8050a55 to
0810bda
Compare
|
Regarding the failing test, this is what claude suggests "E2E test bug in test/e2e/thv-operator/virtualmcp/virtualmcp_authserver_config_test.go: the test creates a VirtualMCPServer with IncomingAuth.Type = "anonymous" alongside a non-nil AuthServerConfig. During reconciliation, runValidations → validateAuthServerConfig will pass (issuer + upstreams are set) and momentarily set AuthServerConfigValidated = True. But then ensureVmcpConfigConfigMap → ValidateAuthServerIntegration → validateAuthServerRequiresOIDC will fail ("embedded auth server requires OIDC incoming auth"), overwriting the condition to False. The test waits for "True" and will always time out. The test needs either OIDC incoming auth configured, or the test should assert that the condition ends up False (if anonymous auth with an embedded AS is intentionally unsupported).E2E test bug in test/e2e/thv-operator/virtualmcp/virtualmcp_authserver_config_test.go: the test creates a VirtualMCPServer with IncomingAuth.Type = "anonymous" alongside a non-nil AuthServerConfig. During reconciliation, runValidations → validateAuthServerConfig will pass (issuer + upstreams are set) and momentarily set AuthServerConfigValidated = True. But then ensureVmcpConfigConfigMap → ValidateAuthServerIntegration → validateAuthServerRequiresOIDC will fail ("embedded auth server requires OIDC incoming auth"), overwriting the condition to False. The test waits for "True" and will always time out. The test needs either OIDC incoming auth configured, or the test should assert that the condition ends up False (if anonymous auth with an embedded AS is intentionally unsupported)." |
d1d62a3 to
21a42ec
Compare
|
@jerm-dro would you mind re-stamping? There were conflicts plus rebasing the PR atop origin/main caused one function to go over the cyclomatic limit. No changes to the PR logic. |
|
@jhrozek I can stamp after merge conflicts are resolved |
The VirtualMCPServer operator lacked the ability to convert an inline EmbeddedAuthServerConfig into an authserver.RunConfig and mount the necessary secrets onto the vMCP pod. Export BuildAuthServerRunConfig from controllerutil (previously the unexported buildEmbeddedAuthServerRunnerConfig used only by MCPServer) and call it from the VirtualMCPServer converter. This avoids duplicating ~450 lines of conversion logic (signing keys, HMAC secrets, upstream providers, Redis storage with Sentinel) and ensures both controllers use identical mount paths, env var naming, and Redis key prefix format. Operator side: serialize the RunConfig as a separate ConfigMap key (authserver-config.yaml) alongside config.yaml. Mount auth server volumes and env vars onto the deployment via GenerateAuthServerVolumes and GenerateAuthServerEnvVars. Cross-validate auth server config against backend strategies via ValidateAuthServerIntegration. Binary side: load sibling authserver-config.yaml if present, construct EmbeddedAuthServer, and pass it to the server config. Fail closed on read errors other than file-not-found. Fixes #4284
ValidateAuthServerIntegration (added in 0810bda) requires OIDC incoming auth when AuthServerConfig is present. The pre-existing E2E test used anonymous auth, causing the condition to be overwritten to False and the test to time out. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Convert function exceeded the gocyclo threshold (17 > 15) after the rebase added both SessionStorage and AuthServerConfig conversion. Extract the SessionStorage block into a standalone helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
21a42ec to
62337a2
Compare
Summary
AuthServerConfiginto anauthserver.RunConfigor mount auth server secrets onto the vMCP pod. This blocks end-to-end OAuth flows for vMCP.BuildAuthServerRunConfigfromcontrollerutil(previously unexported, MCPServer-only) and call it from the vMCP converter, reusing ~450 lines of conversion logic (signing keys, HMAC secrets, upstream providers, Redis/Sentinel storage).authserver-config.yaml), mount auth server volumes/env vars on the deployment, cross-validate auth server config against backend strategies. Spec validation errors now set a status condition instead of requeueing indefinitely.authserver-config.yamlif present, constructEmbeddedAuthServer, fail closed on errors.Fixes #4284
Type of change
Test plan
task test)Tested end-to-end as part of the full
vmcp-add-as-scaffolding-5branch with a deployed VirtualMCPServer running the embedded auth server.Changes
controllerutil/authserver.goBuildAuthServerRunConfig, take explicitallowedAudiences/scopesSupportedparams instead of*oidc.OIDCConfigvmcpconfig/converter.goConvert()returns(*Config, *RunConfig, error); addconvertAuthServerConfig,deriveAllowedAudiences,deriveScopesSupportedvirtualmcpserver_vmcpconfig.goValidateAuthServerIntegrationwith status condition on failurevirtualmcpserver_controller.goSpecValidationErrortype andhandleSpecValidationErrorhelper for no-requeue on spec errorsvirtualmcpserver_deployment.goAuthServerConfigis setcmd/vmcp/app/commands.goloadAuthServerConfigloads sibling file; constructEmbeddedAuthServerinrunServeSpecial notes for reviewers
deriveAllowedAudiencesuses onlyResource(RFC 8707), no fallback toAudience— consistent with the MCPServer path which hard-requiresResourceURL.deriveScopesSupportednormalizes empty slices to nil so the auth server always applies its default scopes when none are configured.SpecValidationErrortype distinguishes spec errors (no requeue, set status condition) from transient errors (requeue with backoff), matching the existingvalidateAuthServerConfigpattern.🤖 Generated with Claude Code