Repository navigation
Conversation
JAORMX
approved these changes
Mar 28, 2025
tgrunnagle
added a commit
that referenced
this pull request
Nov 19, 2026
Review findings on the OBO operator port (PR #7201): - #10: a mirrored Valid=False/InvalidConfig from a malformed obo source was mistaken for a locally-owned failure and stuck on MCPServer and MCPRemoteProxy after the source healed to the same spec. Mirrored condition messages now carry a fixed prefix, and the mirror clear and both same-hash guards skip conditions that carry it. - #9, #42: Reconcile-level tests for the terminal obo-without-OIDC path on MCPServer and MCPRemoteProxy; MCPRemoteProxy now retries when that rejection cannot be persisted instead of dropping it. - #40: split the MCPServer terminal branch into its own early return. - #41: table-test logOBOSecretEnvVarError redaction, and add an MCPRemoteProxy OBO env var error-path test. - #43, #44, #25, #26: fix stale or inconsistent comments, including the deprecation notes and the vMCP exception for registered handlers. - #37: rename OBOVMCPSecretEnvVar to OBOVMCPSecretEnvVars. - #36, #38: reject cacheSkew above MaxInt32 seconds as the vMCP converter does, and cover blank fields, truncation and Reason. - #39: append a hash of the raw config name to the vMCP OBO env var so names that sanitize alike no longer collide. - #45: two-OBO-backend cases for the vMCP secret discovery paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tgrunnagle
added a commit
that referenced
this pull request
Nov 23, 2026
* Support Entra OBO backend auth in OSS Microsoft Entra on-behalf-of was a working strategy only in the private enterprise overlay; OSS builds exposed the CRD but every dispatch point returned ErrEnterpriseRequired or a 503 stub. Make it a built-in strategy for MCPServer, MCPRemoteProxy, VirtualMCPServer and MCPServerEntry backends (issue #7199): - Port the Entra exchanger, token cache and exchange contract into pkg/auth/obo/{entra,cache,exchange}, kept free of Kubernetes imports (guard test), and make the real middleware the default factory. - Validate obo configs, build the RunConfig middleware and mount the client secret in controllerutil. Reject an MCPServer or MCPRemoteProxy that references obo without oidcConfigRef as InvalidConfig. - Add the real vMCP converter and strategy. Mount each OBO backend's secret in the vMCP pod under a per-config env var so two OBO backends no longer collide on TOOLHIVE_OBO_CLIENT_SECRET. - Keep RegisterOBOHandler, obo.RegisterFactory, RegisterOBOStrategy, ErrEnterpriseRequired and ConditionReasonEnterpriseRequired as deprecated overrides so the enterprise overlay keeps compiling until it is removed (#7200). Co-Authored-By: Claude Opus 5.5 <[email protected]> * Return 502 when the Entra endpoint times out The HTTP client's own timeout matches context.DeadlineExceeded, so the exchanger reported it as caller cancellation and the OBO middleware wrote no response, giving a still-connected client an empty 200. Only treat a context error as cancellation when the caller's context is done; a token endpoint timeout is now a transient failure (502). Also rename the vMCP env var helper to GenerateUniqueOBOSecretEnvVarName, the name the issue specifies. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Fix codespell findings in OBO code Co-Authored-By: Claude Opus 5.5 <[email protected]> * Regenerate swagger and SDK for schema order Swag orders the awssts schemas differently once the OBO packages are in the import graph; the content is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Keep OBO clientSecretEnv unresolved at load The operator renders inline VirtualMCPServer OBO backends with only clientSecretEnv. The YAML loader copied the env value into clientSecret without clearing clientSecretEnv, so the validator and the OBO strategy rejected the backend as setting both, and vMCP failed at startup. The loader now only checks the variable is set, as it does for tokenExchange; the strategy reads it at request time. Addresses #7201 review comments: - HIGH pkg/vmcp/config/yaml_loader.go:163 (review body): operator-generated inline OBO backends fail vMCP startup validation Co-Authored-By: Claude Opus 5.5 <[email protected]> * Pin SDK awssts names and fix middleware docs Swag emits the awssts schemas under their short name once the OBO packages are in the import graph, which renamed the exported SDK types (AuthAWSSTSConfig became AWSSTSConfig). The normalizer now maps the short form to the path form, so the SDK matches main again regardless of which name swag picks. docs/middleware.md: fix the audit anchor broken by the renumbering and list the OBO middleware in the chain overview and execution order. Addresses #7201 review comments: - MEDIUM sdk/go/client/oas_schemas_gen.go (review body): swagger regeneration renamed exported SDK types - MEDIUM docs/middleware.md:50 (review body): broken #9-audit-middleware link - MEDIUM docs/middleware.md:11 (review body): OBO missing from the chain overview and execution-order lists Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address operator review findings for OBO Review findings on the OBO operator port (PR #7201): - #10: a mirrored Valid=False/InvalidConfig from a malformed obo source was mistaken for a locally-owned failure and stuck on MCPServer and MCPRemoteProxy after the source healed to the same spec. Mirrored condition messages now carry a fixed prefix, and the mirror clear and both same-hash guards skip conditions that carry it. - #9, #42: Reconcile-level tests for the terminal obo-without-OIDC path on MCPServer and MCPRemoteProxy; MCPRemoteProxy now retries when that rejection cannot be persisted instead of dropping it. - #40: split the MCPServer terminal branch into its own early return. - #41: table-test logOBOSecretEnvVarError redaction, and add an MCPRemoteProxy OBO env var error-path test. - #43, #44, #25, #26: fix stale or inconsistent comments, including the deprecation notes and the vMCP exception for registered handlers. - #37: rename OBOVMCPSecretEnvVar to OBOVMCPSecretEnvVars. - #36, #38: reject cacheSkew above MaxInt32 seconds as the vMCP converter does, and cover blank fields, truncation and Reason. - #39: append a hash of the raw config name to the vMCP OBO env var so names that sanitize alike no longer collide. - #45: two-OBO-backend cases for the vMCP secret discovery paths. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Harden OBO tests and error handling Address review findings on the Entra OBO port so the tests fail when the behavior they cover breaks, and tighten a few error paths. Behavior changes: - #18 Classify HTTP 429, HTTP 408 and the OAuth error temporarily_unavailable as transient (the proxy answers 502). - #29 The vMCP strategy no longer returns Entra's error and error_description to MCP clients. It logs the detail server-side and returns a generic error that wraps only the entra sentinel. - #8 The vMCP converter rejects an empty client secret value when it resolves the secret. It also rejects a whitespace-only clientId, as the operator does. - #20 Remove the unused entra.Config and entra.New. Production code uses TokenURL with NewFromTokenURL; the tests now do too. Test hardening: - pkg/auth/obo: #2 provider-mode identities carry an inbound token that must not be used as a fallback; #15 DefaultFactory's skew wiring; #16 audit event table and port-stripped source; #17 test rename, t.Cleanup. - entra: #3 the body-cap test needs truncation to fail; #4 redirect refusal for default and injected clients, 307 and 308; #5 and #21 more classification rows (2xx with an error member, claims-only, AADSTS50079-only, 5xx precedence, lower-case bearer, body read failure, zero and negative expires_in). - cache: #6 timeouts on every blocking wait; #22 coalescing test proves followers join the flight; #23 coalesced error, the exact skew boundary, TTL shorter than skew, WithClock(nil). - pkg/runner: #24 RegisterFactory override reaches the runner, and assert instead of require in the handler. - pkg/vmcp/auth: #7 Authenticate error branches and pinned config-before-health-check order; #27 env.Reader reaches the registered factory; #28 comment fix; #31 and #35 real-builder caching per user and skew; #32 exchanger cache key table; #33 double-checked lock under contention; #34 unset ClientSecretEnv. Cleanup: #14 move NewInteractionRequiredAuditEvent to audit.go; #19 reword the validateTenant comment; #30a comment the strategy's mu and exchangers fields separately; #30b make parseResponse a plain function that takes the receive time. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Clear stale OBO incoming-auth rejection on revert The same-hash guard held the local obo-without-OIDC InvalidConfig after the referenced config reverted from obo to its earlier spec, because the rejection returns before the stored hash advances. The guard no longer holds that condition; it is re-derived on every reconcile. Addresses #7201 review comments: - MEDIUM cmd/thv-operator/controllers/mcpserver_controller.go:2580 (4635357068): same-hash guard holds stale local obo InvalidConfig - LOW cmd/thv-operator/controllers/external_auth_mirror.go:37 (4635357091): document mirrored message format, test prefix invariant - LOW cmd/thv-operator/controllers/mcpserver_externalauth_test.go:969 (4635357099): test MCPServer terminal status-write failure Co-Authored-By: Claude Opus 5.5 <[email protected]> * Tighten OBO vMCP errors, validation and tests A rejected client credential now reads as a generic exchange failure to MCP clients, a whitespace clientId fails strategy validation, and a 429 or 408 with an unparsable body is transient like one with a JSON body. Addresses #7201 review comments: - MEDIUM pkg/vmcp/auth/strategies/obo_test.go:699 (4635357079): deterministic exchanger contention test - MEDIUM pkg/vmcp/config/yaml_loader_test.go:772 (4635357085): loader OBO error-path tests - LOW docs/middleware.md:529 (4635357111): split the OBO 502 table row - LOW pkg/auth/obo/entra/exchanger.go:343 (4635357122): unparsable 429/408 is transient - LOW pkg/vmcp/auth/strategies/obo.go:248 (4635357133): opaque invalid_client error - LOW pkg/vmcp/auth/strategies/obo.go:322 (4635357139): reject whitespace clientId - LOW pkg/vmcp/auth/strategies/obo_test.go:460 (4635357146): assert diagnostic log per error class Co-Authored-By: Claude Opus 5.5 <[email protected]> * Share CA bundle message and tighten operator tests Addresses #7201 review comments: - LOW cmd/thv-operator/controllers/external_auth_mirror_test.go:378 (4661456788): controllers and the prefix test share ctrlutil.InvalidCABundleMessage; the CA bundle entry uses InvalidCABundle - LOW cmd/thv-operator/controllers/mcpserver_controller.go:2571 (4661456797): doc comment names handleExternalAuthConfig - LOW cmd/thv-operator/controllers/mcpserver_externalauth_test.go:968 (4661456805): missing-config row asserts the not-found error and that no obo rejection is recorded - LOW docs/arch/09-operator-architecture.md:241 (4661456811): drop change history, note the empty-message form Co-Authored-By: Claude Opus 5.5 <[email protected]> * Replace OBO test hook with a store seam Addresses #7201 review comments: - LOW pkg/vmcp/auth/strategies/obo.go:67 (4661456815): the exchanger map moves behind an unexported oboExchangerStore interface that the contention test wraps, removing the afterReadMiss hook field - LOW pkg/vmcp/auth/strategies/obo.go:351 (4661456823): a whitespace-only tokenUrl fails validation Co-Authored-By: Claude Opus 5.5 <[email protected]> * Align OBO test messages and CA bundle doc Addresses #7201 review comments: - LOW pkg/vmcp/auth/strategies/obo_test.go:712 (4667645696): barrier test messages use the store seam's vocabulary - LOW cmd/thv-operator/pkg/controllerutil/ca_bundle.go:41 (4667645702): doc comment states the mirrored-prefix invariant instead of naming a test in another package - LOW cmd/thv-operator/controllers/mcpserver_externalauth_test.go:1013 (4667645707): missing-config row asserts no Validated condition Co-Authored-By: Claude Opus 5.5 <[email protected]> * Add OBO 401 challenges and audience as resource Addresses #7201 review comments (review 6024926356): - body:www-authenticate: every OBO 401 carries a Bearer invalid_token challenge; invalid_grant in upstream-provider mode asks the client to re-authenticate with the embedded auth server - body:audience-scope: a bare audience is sent to Entra as <audience>/.default, as MSAL treats a resource; the field docs say so - body:remote-injector: the remote token injector is skipped when the OBO middleware is present, not only token exchange - body:docs: docs/middleware.md section 9 records the 403 departure from Microsoft's insufficient_claims guidance; disableUpstreamTokenInjection lists OBO among the incompatible middlewares Co-Authored-By: Claude Opus 5.5 <[email protected]> * Default OBO subject provider behind auth server Addresses #7201 review comments (review 6024926356): - body:subject-provider: vMCP defaults an empty obo subjectTokenProviderName to the embedded auth server's upstream, and rejects it as ambiguous with more than one upstream, as xaa does; the proxy runner defaults it to the upstream the upstream swap middleware uses, so OBO no longer sends ToolHive's session JWT to Entra Co-Authored-By: Claude Opus 5.5 <[email protected]> * Tighten OBO secret, skew and token URL checks Addresses #7201 review comments (review 6024926356): - body:empty-secret: verifyOBOClientSecret rejects an empty Secret value, which the proxy's middleware factory would refuse at startup - body:skew-bound: MiddlewareParameters.Validate caps cacheSkewSeconds at MaxInt32, the operator's bound, so a hand-written RunConfig cannot overflow time.Duration in cache.New - body:token-url: the vMCP strategy validates tokenUrl with entra.ValidateTokenURL, so a relative or non-https URL fails Validate instead of passing health checks and failing every call - body:env-var-cases: TestAddOBOSecretEnvVars covers every external auth type again Co-Authored-By: Claude Opus 5.5 <[email protected]> * Share OBO exchanger builder and drop stale ones Addresses #7201 review comments (review 6024926356): - body:shared-builder: obo.NewCachedExchanger builds the cached Entra exchanger for both the proxy middleware and the vMCP strategy, so the two no longer need a comment asking to keep them in parity - body:store: the vMCP exchanger store is a mutex and a map; building does no I/O, so the read-write lock and double check are gone - body:eviction: a new client secret for a client the strategy already serves replaces the exchanger built with the old secret, so a rotation does not leave the old secret and its cached tokens in memory Co-Authored-By: Claude Opus 5.5 <[email protected]> * Document OBO limits and runner default choice Addresses #7201 review comments: - LOW mcpexternalauthconfig_types.go:269 (4669447143): CacheSkew doc states the math.MaxInt32 bound; vMCP OBOConfig comment mirrors it - LOW docs/arch/10-virtual-mcp-architecture.md:1091 (4669447157): one exchanger per client replaced on rotation, subject default, audience - LOW docs/middleware.md:532 (4669447171): split the invalid_grant row by subject source - LOW pkg/auth/obo/middleware.go:290 (4669447186): state that the re-auth challenge does not cure missing consent - LOW pkg/runner/middleware.go:317 (4669447223): state the deliberate first-upstream divergence from vMCP and why Co-Authored-By: Claude Opus 5.5 <[email protected]> * Strengthen OBO tests the review found loose Addresses #7201 review comments: - LOW pkg/auth/obo/middleware_test.go:673 (4669447196): exact-match the upstream re-auth challenge and body; declare challenges up front - LOW pkg/auth/obo/parameters_test.go:52 (4669447206): table test for exchange.Target, including "/" and a ".default/" audience - LOW pkg/runner/middleware_test.go:471 (4669447240): several, unnamed and zero upstreams, and a non-OBO middleware beside an OBO one - LOW pkg/runner/middleware_test.go:471 (4669447257): non-object and non-string parameter errors, and null parameters - LOW pkg/vmcp/auth/strategies/obo_test.go:646 (4669447271): hold the first build open so a lost lock yields one build per caller - LOW pkg/vmcp/auth/strategies/obo_test.go:685 (4669447286): a failed build for a rotated secret keeps the working Exchanger Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
No description provided.