Repository navigation
Expose group-based upstream filter via vMCP CRD - #6740
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6740 +/- ##
==========================================
- Coverage 79.51% 79.51% -0.01%
==========================================
Files 814 814
Lines 82534 82577 +43
==========================================
+ Hits 65623 65657 +34
- Misses 16906 16915 +9
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
hellouz818
force-pushed
the
feature/6675-pr3-crd
branch
2 times, most recently
from
October 8, 2026 01:59
40e2300 to
e599d67
Compare
6 tasks done
hellouz818
force-pushed
the
feature/6675-pr3-crd
branch
from
October 13, 2026 10:45
e599d67 to
12aad7f
Compare
Surface the auth-server GroupBasedFilter through VirtualMCPServerSpec so operators can configure per-user upstream chain narrowing with YAML, without reaching into the embedded auth-server RunConfig directly. The new AuthServerUpstreamFilter field lives beside AuthServerConfig (rather than nested inside EmbeddedAuthServerConfig, which is shared with MCPExternalAuthConfig and has no meaning for multi-upstream filtering). CEL at admission enforces the two cheap cross-field invariants Kubernetes can check cheaply: the field requires authServerConfig, and at least two upstream providers must be configured. The two deeper reference-integrity checks the plan called for — every referenced provider must name a configured non-first upstream, and the mandatory first provider must not be referenced — were originally expressed as CEL but exceeded Kubernetes' static validation cost limit, because upstreamProviders carries no MaxItems bound. They are enforced at reconciliation time instead, by validateAuthServerUpstreamFilter in the VirtualMCPServer controller, which surfaces a terminal AuthServerConfigValidated=False condition. A proper restoration would require bounding the shared upstreamProviders type so the cost estimator can size it; keeping that out of scope here keeps the shared EmbeddedAuthServerConfig type unchanged for MCPExternalAuthConfig consumers. Reconciliation also protects against admission bypass (fake client, pre-CEL stored object): the full Go filter constructor runs again against the configured upstream list before the ConfigMap is written, rejecting malformed configuration before it reaches a crash-looping pod. The vMCP converter extends the shared BuildAuthServerRunConfig call with the vMCP-only field translation, keeping the shared builder free of vMCP-specific concerns. The claim field documents where its value is resolved from, because the filter is fail-closed and the CRD reference is what an operator reads before enabling it: the first upstream must be configured to carry the claim in its ID token or userinfo response, so an IdP that does not emit it there locks every principal out. Generated artifacts (deepcopy, CRD manifests, CRD reference) are regenerated via task operator-generate, task operator-manifests, and task crdref-gen. Refs: stacklok#6675 Signed-off-by: hellouz818 <[email protected]>
hellouz818
force-pushed
the
feature/6675-pr3-crd
branch
from
October 13, 2026 11:04
12aad7f to
89a2822
Compare
hellouz818
marked this pull request as ready for review
October 13, 2026 11:15
hellouz818
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
blkt,
jerm-dro,
jhrozek,
rdimitrov,
reyortiz3 and
tgrunnagle
as code owners
October 13, 2026 11:15
1 task
JAORMX
approved these changes
Oct 15, 2026
1 task
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
PR 3/3 of #6675. Surfaces the auth-server
GroupBasedFilter(added in #6739) throughVirtualMCPServerSpecso operators can configure per-user upstream chain narrowing with YAML.The new
AuthServerUpstreamFilterfield lives besideAuthServerConfig(rather than nested inside the sharedEmbeddedAuthServerConfig, which is also used byMCPExternalAuthConfigwhere multi-upstream filtering has no meaning). Admission-time CEL enforces two cheap cross-field invariants: the field requiresauthServerConfig, and at least two upstream providers must be configured. Reconciliation re-runs the full Go filter constructor against the configured upstream list so a resource that bypassed admission (fake client, pre-CEL stored object) is rejected with a terminalAuthServerConfigValidated=Falsecondition before its ConfigMap is written.The vMCP converter extends the shared
BuildAuthServerRunConfigcall with the vMCP-only field translation, keeping the shared builder free of vMCP-specific concerns.VirtualMCPServerSpec+ CEL + OpenAPI markersConvertUpstreamFilter) layered onBuildAuthServerRunConfigvalidateAuthServerUpstreamFilter)Both earlier PRs in the series are merged, so this one now sits directly on
main. Refs #6675Type of change
Test plan
task test) — 6 cases forvalidateAuthServerUpstreamFilter, 4 cases forConvertUpstreamFiltertest-integration/virtualmcp/virtualmcpserver_upstreamfilter_cel_test.goexercising the CEL rules through the real apiservertask lint) — 0 issuestask docs-verify,task operator-generate,task operator-manifests,task crdref-gen)slackoptional upstream, successfully invokes Slack tools via Claude Code, withatlassian/cobi/salesforceupstream tokens correctly absent (confirmed via operator audit logs and absent-token warnings)API Compatibility
v1beta1API.New optional field on
VirtualMCPServerSpec. Omitting it preserves pre-filter behavior (full chain). No existing CRs change meaning.Does this introduce a user-facing change?
Yes — new optional field
VirtualMCPServer.spec.authServerUpstreamFilterlets operators narrow the OAuth chain per user based on an identity claim. See the "Per-User Upstream Filtering" section indocs/arch/10-virtual-mcp-architecture.mdfor the configuration shape and semantics.Special notes for reviewers
Where the claim comes from
The filter is fail-closed on an absent claim, and the CRD reference is what an operator reads before enabling the field, so
claim's doc comment states where the value is resolved from: the identity the first upstream produces — the validated ID token for an OIDC upstream, the userinfo response for a pure OAuth2 one. Groups carried only in an access token never reach it. An IdP that does not emit the claim locks every principal out. Before enabling the filter, configure the first upstream to include the claim in its ID token or userinfo response, and request any required scopes. This mirrors theGroupBasedFilterConfig.Claimdocumentation added during the #6739 review, on the surface operators actually configure.CEL cost budget
The two deeper reference-integrity CEL rules the issue plan called for (every referenced provider must name a configured non-first upstream; mandatory first provider must not be referenced) were originally implemented but exceeded Kubernetes' static validation cost limit because
upstreamProvidershas noMaxItemsbound.They are enforced at reconciliation time instead, by
validateAuthServerUpstreamFilter, which surfaces a terminalAuthServerConfigValidated=Falsecondition. The reconciler calls the same Go constructor used in #6739, keeping reconciliation validation consistent with auth-server initialization.A proper restoration path would add
MaxItemsbounds on the sharedupstreamProviderstype to tame the cost estimator; keeping that out of scope here keeps the sharedEmbeddedAuthServerConfigtype unchanged forMCPExternalAuthConfigconsumers. Happy to open a follow-up PR for the bounded-list restoration if preferred.Note on OAuth-flow E2E
The issue plan includes a functional E2E deliverable. #6739 added an integration test that drives the filter from a
RunConfigthrough the real multi-leg authorization flow with mock OIDC upstreams.This PR adds no further flow-level coverage: admission behavior is covered by envtest against a real apiserver, and reconciliation validation and field conversion are covered by unit tests. The end-to-end behavior has additionally been validated manually against an internal MCP Hub deployment.
This follows the test layering used for the SPIFFE CRD exposure in #6500: envtest coverage for admission behavior, without a full OAuth-flow E2E.
Follow-up work tracked
pkg/vmcp/auth/strategies/xaa.gostill carries its own claim array decoding. Cedar's array-only site moved ontopkg/auth/claimsin Add shared JWT claim string-array decoder #6738; the remaining Cedar paths (normalizeMultiValuedClaims,addMultiValuedClaimSets) also accept scalar strings, so they are not candidates for the array-only helper.MaxItemsbounds on the shared upstream type.