Skip to content

Carry multi_valued_claims through vMCP authz path - #7127

Open
bharathvemula wants to merge 1 commit into
stacklok:mainfrom
bharathvemula:fix/6737-multi-valued-claims-vmcp
Open

bharathvemula wants to merge 1 commit into
stacklok:mainfrom
bharathvemula:fix/6737-multi-valued-claims-vmcp

Conversation

@bharathvemula

Copy link
Copy Markdown

Summary

When a VirtualMCPServer references an MCPAuthzConfig that sets multi_valued_claims, the setting was accepted and validated but never reached the Cedar authorizer: the vMCP converter copied only an allow-list of Cedar options and vmcpconfig.AuthzConfig had no MultiValuedClaims field. As a result the claimset_<name> attribute was never created, policies using it always denied, and no error or warning was emitted.

What changed:

  • Added MultiValuedClaims []string to vmcpconfig.AuthzConfig (pkg/vmcp/config) and to the AuthzConfigRef spec-level override (cmd/thv-operator/api/v1beta1).
  • The converter now copies opts.MultiValuedClaims through both the MCPAuthzConfig-ref path (resolveAuthzConfigRef) and the ConfigMap path (convertAuthzConfig), with the spec-level override winning over the ConfigMap value, mirroring GroupClaimName/RoleClaimName/GroupEntityType.
  • buildCedarAuthzConfig (pkg/vmcp/auth/factory) now forwards it into cedar.ConfigOptions.
  • Added guard tests that fail when a cedar.ConfigOptions field is not mapped through: a converter guard covering both authz sources (PrimaryUpstreamProvider is the one deliberate exclusion — it is resolved from spec.authServerConfig, never from the shared authz payload) and a buildCedarAuthzConfig guard comparing every option field against AuthzConfig.
  • Regenerated deepcopy, CRDs (both served versions, v1alpha1 and v1beta1) and docs/operator/crd-api.md with the operator Taskfile tasks; added a short upgrade note to docs/authz.md.
  • Inline authz config is out of scope, as requested.

Fixes #6737

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Verification evidence:

  • Repro before the fix: a converter test feeding an MCPAuthzConfig payload with "multi_valued_claims":["scope"] showed the converted authz JSON with no multiValuedClaims key (test failed as expected); after the fix the same conversion carries ["scope"] through.
  • go test ./cmd/thv-operator/pkg/vmcpconfig/... ./pkg/vmcp/... ./cmd/thv-operator/api/... -count=1 — all packages pass, including the new TestConvertAuthzConfig_MapsEveryCedarOption (ref + ConfigMap paths) and TestBuildCedarAuthzConfig_MapsEveryCedarOption.
  • golangci-lint run ./cmd/thv-operator/pkg/vmcpconfig/... ./pkg/vmcp/config/... ./pkg/vmcp/auth/factory/... ./cmd/thv-operator/api/... — 0 issues. gofmt clean.
  • CRD check: multiValuedClaims appears in both the v1alpha1 and v1beta1 versions of the VirtualMCPServer CRD (and in the MCPServer/MCPRemoteProxy CRDs, which share AuthzConfigRef).

API Compatibility

  • This PR does not break the v1beta1 API, OR the api-break-allowed label is applied and the migration guidance is described above.

This PR only adds an optional multiValuedClaims field; no existing field changes.

Does this introduce a user-facing change?

Yes. multi_valued_claims is now honoured for VirtualMCPServer the same way it is for thv run, MCPServer, and MCPRemoteProxy: a listed claim is exposed to Cedar as claim_<name> (space-delimited string) and claimset_<name> (a Cedar Set of the claim's elements), so policies such as principal.claimset_scope.contains("weather:read") now permit as documented.

Upgrade note: deployments that already list multi_valued_claims will see claim_<name> change from a Cedar Set to a joined string once it is honoured. Audit any like/substring policies on a listed claim before upgrading, and prefer claimset_<name> with .contains for exact-element membership.

Special notes for reviewers

  • The fork branch is based on the fork's main, which is 19 commits behind upstream main; the PR diff itself is the single fix commit only.
  • The new MultiValuedClaims field on AuthzConfigRef is a spec-level override for the ConfigMap path (and applies to the inline path the same way the sibling claim-mapping fields do); the MCPAuthzConfig-ref path copies the value from the referenced config, with no spec override, matching the existing behaviour for GroupClaimName/RoleClaimName/GroupEntityType.

A VirtualMCPServer referencing an MCPAuthzConfig that sets multi_valued_claims had the setting silently dropped: the vMCP converter copied only an allow-list of Cedar options and AuthzConfig had no MultiValuedClaims field, so claimset_* attributes never reached Cedar and policies using them always denied.

Add MultiValuedClaims to vmcpconfig.AuthzConfig and to the AuthzConfigRef spec-level override, copy it through both the MCPAuthzConfig-ref and ConfigMap paths in the converter, and forward it into cedar.ConfigOptions in buildCedarAuthzConfig. Regenerate deepcopy, CRDs (both served versions) and docs/operator/crd-api.md.

Add guard tests that fail when a cedar.ConfigOptions field is not mapped through: a converter guard covering both authz sources (PrimaryUpstreamProvider is the one deliberate exclusion, resolved from spec.authServerConfig) and a buildCedarAuthzConfig guard comparing every option field against AuthzConfig.

Behaviour change: deployments that already list multi_valued_claims will see claim_<name> change from a Cedar Set to a joined string once it is honoured; audit like/substring policies on listed claims and prefer claimset_<name> with .contains.

Fixes stacklok#6737

Signed-off-by: Bharath Vemula <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

multi_valued_claims in MCPAuthzConfig is silently ignored for VirtualMCPServer

1 participant