Expose upstream provider allowPrivateIP in MCPExternalAuthConfig - #6288
Draft
alex-feel wants to merge 1 commit into
Draft
Expose upstream provider allowPrivateIP in MCPExternalAuthConfig#6288alex-feel wants to merge 1 commit into
alex-feel wants to merge 1 commit into
Conversation
The embedded auth server's upstream provider config has supported allow_private_ips since stacklok#5618, and the runner already propagates it, but the operator CRD never exposed the field and the controllerutil builders never set it — so an operator-deployed embedded AS could never federate an IdP that resolves to a private address: the AS exits fail-closed at OIDC discovery and the proxy pod crash-loops. Declaring the provider as type oauth2 with explicit endpoints does not help, because the same host-scoped HTTP client gates the token exchange. Add allowPrivateIP to OIDCUpstreamConfig and OAuth2UpstreamConfig (mirroring the jwksAllowPrivateIP naming precedent on MCPOIDCConfig), map it in buildOIDCUpstreamRunConfig and buildOAuth2UpstreamRunConfig, and regenerate the CRD manifests (MCPExternalAuthConfig and VirtualMCPServer, which embeds the same types). Closes stacklok#4523 Signed-off-by: Aleksandr Filippov <71711753+alex-feel@users.noreply.github.com>
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.
Summary
The embedded auth server's upstream provider config has supported
allow_private_ipssince #5618 —pkg/authserver/config.gocarries it on bothOIDCUpstreamRunConfigandOAuth2UpstreamRunConfig, andpkg/authserver/runner/embeddedauthserver.gopropagates it into provider construction — but the operator layer never exposed it:OIDCUpstreamConfig/OAuth2UpstreamConfiginmcpexternalauthconfig_types.gohave no such field andbuildOIDCUpstreamRunConfig/buildOAuth2UpstreamRunConfignever set it (grep -rn AllowPrivateIPs cmd/thv-operator/is empty before this PR).The result: an operator-deployed embedded AS can never federate an IdP that resolves to a private address. The AS exits fail-closed at OIDC discovery —
— and the proxy pod crash-loops. Declaring the provider as
type: oauth2with explicit endpoints does not help: the same host-scoped HTTP client gates the token exchange (newHTTPClientForHostinpkg/authserver/upstream/oauth2.go), so the failure just moves from startup to the first sign-in. Self-hosted IdPs on corporate networks (GitLab, Keycloak behind split-horizon DNS) are a common shape for exactly the deployments the operator targets.What changed:
allowPrivateIP(optional, defaultfalse) added to bothOIDCUpstreamConfigandOAuth2UpstreamConfig, mirroring thejwksAllowPrivateIP/protectedResourceAllowPrivateIPnaming precedent onMCPOIDCConfig— the same per-resource opt-in shape Allow opt-in internal/private remoteUrl hosts for co-located MCP backends (operator ValidateRemoteURL has no allowlist) #5784 discusses forremoteUrl.buildOIDCUpstreamRunConfig/buildOAuth2UpstreamRunConfigmap it onto the existingAllowPrivateIPsrun-config field. Everything below the operator already propagates it end to end, so this is the last missing link.MCPExternalAuthConfig, andVirtualMCPServerwhich embeds the same upstream config types).Closes #4523
Type of change
Test plan
task test) —TestBuildAuthServerRunConfigextended: a new case pins the flag reaching the run config on both provider types, and the existing OIDC case pins the default stayingfalse. Operator unit packages are green locally viago test ./cmd/thv-operator/...; the envtest-based integration suites need the kubebuilder control-plane binaries and run in CI.API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Additive optional field only; default
falsepreserves the current behavior exactly.Does this introduce a user-facing change?
Yes:
MCPExternalAuthConfig(andVirtualMCPServer) upstream providers acceptallowPrivateIP: true, allowing the embedded auth server to federate IdPs that resolve to private addresses. The defaultfalsepreserves the current SSRF-protective behavior.