Unify subject provider defaulting, hard-error xaa#5708
Open
jhrozek wants to merge 1 commit into
Open
Conversation
The YAML and operator paths each defaulted a backend's SubjectProviderName to the first configured upstream, but drifted apart: the YAML path was missing aws_sts entirely (stacklok#5687), so an aws_sts backend with an unset field failed at request time instead of being defaulted. Separately, both paths silently picked upstream[0] for xaa even with multiple upstreams configured, a security-relevant footgun since sending the wrong subject token to Step A yields a confusing IdP error or a token minted for the wrong subject (stacklok#5697). Extract a shared authtypes.DefaultSubjectProviderName helper used by both the YAML (pkg/vmcp/config/defaults.go) and operator (cmd/thv-operator/controllers/virtualmcpserver_controller.go) paths, covering token_exchange, aws_sts, and xaa. xaa now hard-errors on ambiguous multi-upstream configs on both paths; on the operator side this surfaces as a non-fatal per-backend AuthConfigError condition rather than a Reconcile failure. Fixes stacklok#5687, stacklok#5697 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5708 +/- ##
==========================================
+ Coverage 70.63% 70.68% +0.05%
==========================================
Files 667 668 +1
Lines 67607 67641 +34
==========================================
+ Hits 47752 47815 +63
+ Misses 16399 16356 -43
- Partials 3456 3470 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 YAML and operator paths each defaulted a backend's
SubjectProviderNameto the first configured upstream, but drifted apart:aws_stsentirely, so anaws_stsbackend with an unset field failed at request time instead of being defaulted (SubjectProviderName defaulting for aws_sts missing from YAML/thv serve path #5687).upstream[0]forxaaeven with multiple upstreams configured — a security-relevant footgun, since sending the wrong subject token to Step A yields a confusing IdP error or a token minted for the wrong subject (xaa strategy: hard-error on ambiguous SubjectProviderName when multiple upstreams are configured #5697).This extracts a shared
authtypes.DefaultSubjectProviderNamehelper used by both the YAML (pkg/vmcp/config/defaults.go) and operator (cmd/thv-operator/controllers/virtualmcpserver_controller.go) paths, coveringtoken_exchange,aws_sts, andxaa.xaanow hard-errors on ambiguous multi-upstream configs on both paths.AuthConfigErrorcondition (AmbiguousSubjectProvider), consistent with the existing degraded-mode pattern for other auth config errors — the rest of theVirtualMCPServerkeeps reconciling.InjectSubjectProviderNamesnow returns an error, sothv vmcp servefails fast at startup rather than silently guessing.Fixes #5687
Fixes #5697
Type of change
Test plan
task test)task test-e2e)task lint-fix)Does this introduce a user-facing change?
Yes, narrowly: a
xaabackend auth strategy with an emptySubjectProviderNameand 2+ configured upstreams now fails validation instead of silently defaulting to the first upstream. On the operator this surfaces as a per-backend status condition (degraded mode, rest of the server keeps running); on the YAML/CLI path this causesthv vmcp serveto fail at startup. Sincexaasupport merged the day before this change, there are no existing deployments this affects — newxaaadopters will simply need to setSubjectProviderNameexplicitly when configuring more than one upstream.token_exchangeandaws_stsbehavior is unaffected by this change (they continue to default silently); the only behavior fix for them is that the YAML path now also defaultsaws_sts, matching the operator path.Special notes for reviewers
The equivalent ambiguous-upstream defaulting in
pkg/runner/middleware.go(Cedar'sPrimaryUpstreamProvider) has the same footgun this PR fixes forxaa, but is intentionally out of scope here to keep this PR to one logical change. Worth a follow-up issue.Generated with Claude Code