Skip to content

Bump golangci/golangci-lint-action from 2f856675483cb8b9378ee77ee0beb67955aca9d7 to 4696ba8babb6127d732c3c6dde519db15edab9ea - #3

Merged
JAORMX merged 1 commit into
mainfrom
dependabot/github_actions/golangci/golangci-lint-action-4696ba8babb6127d732c3c6dde519db15edab9ea
Mar 24, 2025
Merged

JAORMX merged 1 commit into
mainfrom
dependabot/github_actions/golangci/golangci-lint-action-4696ba8babb6127d732c3c6dde519db15edab9ea

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Mar 24, 2025

Copy link
Copy Markdown
Contributor

Bumps golangci/golangci-lint-action from 2f856675483cb8b9378ee77ee0beb67955aca9d7 to 4696ba8babb6127d732c3c6dde519db15edab9ea.

Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 2f856675483cb8b9378ee77ee0beb67955aca9d7 to 4696ba8babb6127d732c3c6dde519db15edab9ea.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](golangci/golangci-lint-action@2f85667...4696ba8)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot Bot added dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code labels Mar 24, 2025
@JAORMX
JAORMX merged commit 267ef0e into main Mar 24, 2025
@dependabot
dependabot Bot deleted the dependabot/github_actions/golangci/golangci-lint-action-4696ba8babb6127d732c3c6dde519db15edab9ea branch March 24, 2025 15:42
flfeurmou-indeed added a commit to flfeurmou-indeed/toolhive that referenced this pull request Jan 22, 2026
Address reviewer nit stacklok#3: DetectAuthenticationFromServer and discoverIssuerAndScopes
were called in both tryRestoreFromCachedTokens and authenticateWithOAuth.

Now these are called once in Authenticate and the results are passed to both
tryRestoreFromCachedTokens and performOAuthFlow, avoiding redundant network calls.

Signed-off-by: Frédéric LE FEURMOU <[email protected]>
amirejaz added a commit that referenced this pull request Jan 22, 2026
* feat(auth): persist OAuth tokens across workload restarts

This change enables remote MCP servers (like Datadog and Glean) to
restore their OAuth sessions after workload restarts without requiring
a new browser-based login.

Changes:
- Add CachedAccessToken, CachedRefreshToken, CachedTokenExpiry fields
  to remote.Config for token persistence
- Create PersistingTokenSource wrapper to save tokens when refreshed
- Modify Handler.Authenticate to restore from cached tokens when available
- Add token persister callback in runner to save tokens to config state

Fixes #3331

Signed-off-by: Frédéric LE FEURMOU <[email protected]>

* chore: retry CI

Signed-off-by: Frédéric LE FEURMOU <[email protected]>

* refactor(auth): store OAuth tokens in secret manager

Address reviewer feedback:
- Store refresh tokens securely in secret manager instead of plain text config
- Remove access token caching (can be regenerated from refresh token)
- Add TokenTypeOAuthRefreshToken for proper secret categorization
- Gracefully handle missing secret manager (tokens won't persist but OAuth works)

Security improvement: tokens are now stored in OS keyring/encrypted storage,
config only contains the secret reference (e.g., OAUTH_REFRESH_TOKEN_workload)

Signed-off-by: Frédéric LE FEURMOU <[email protected]>

* refactor(auth): dedupe discovery calls in Authenticate

Address reviewer nit #3: DetectAuthenticationFromServer and discoverIssuerAndScopes
were called in both tryRestoreFromCachedTokens and authenticateWithOAuth.

Now these are called once in Authenticate and the results are passed to both
tryRestoreFromCachedTokens and performOAuthFlow, avoiding redundant network calls.

Signed-off-by: Frédéric LE FEURMOU <[email protected]>

* refactor: only persist when refresh token changes

Avoids unnecessary writes since refresh tokens are long-lived
and usually don't change on every access-token refresh.

* fix: re-register client dynamically when restoring cached tokens

Some MCP servers require client credentials for token refresh.
When no configured client_id exists and a registration endpoint
is available, perform dynamic client registration before attempting
to restore from cached tokens.

This defers #3335 (persisting client credentials) to a separate PR
while still allowing token restoration to work for servers that
require client credentials.

* Revert "fix: re-register client dynamically when restoring cached tokens"

This reverts commit c82408a.

---------

Signed-off-by: Frédéric LE FEURMOU <[email protected]>
Co-authored-by: Muhammad Amir Ejaz <[email protected]>
therealnb pushed a commit that referenced this pull request Jan 23, 2026
* feat(auth): persist OAuth tokens across workload restarts

This change enables remote MCP servers (like Datadog and Glean) to
restore their OAuth sessions after workload restarts without requiring
a new browser-based login.

Changes:
- Add CachedAccessToken, CachedRefreshToken, CachedTokenExpiry fields
  to remote.Config for token persistence
- Create PersistingTokenSource wrapper to save tokens when refreshed
- Modify Handler.Authenticate to restore from cached tokens when available
- Add token persister callback in runner to save tokens to config state

Fixes #3331

Signed-off-by: Frédéric LE FEURMOU <[email protected]>

* chore: retry CI

Signed-off-by: Frédéric LE FEURMOU <[email protected]>

* refactor(auth): store OAuth tokens in secret manager

Address reviewer feedback:
- Store refresh tokens securely in secret manager instead of plain text config
- Remove access token caching (can be regenerated from refresh token)
- Add TokenTypeOAuthRefreshToken for proper secret categorization
- Gracefully handle missing secret manager (tokens won't persist but OAuth works)

Security improvement: tokens are now stored in OS keyring/encrypted storage,
config only contains the secret reference (e.g., OAUTH_REFRESH_TOKEN_workload)

Signed-off-by: Frédéric LE FEURMOU <[email protected]>

* refactor(auth): dedupe discovery calls in Authenticate

Address reviewer nit #3: DetectAuthenticationFromServer and discoverIssuerAndScopes
were called in both tryRestoreFromCachedTokens and authenticateWithOAuth.

Now these are called once in Authenticate and the results are passed to both
tryRestoreFromCachedTokens and performOAuthFlow, avoiding redundant network calls.

Signed-off-by: Frédéric LE FEURMOU <[email protected]>

* refactor: only persist when refresh token changes

Avoids unnecessary writes since refresh tokens are long-lived
and usually don't change on every access-token refresh.

* fix: re-register client dynamically when restoring cached tokens

Some MCP servers require client credentials for token refresh.
When no configured client_id exists and a registration endpoint
is available, perform dynamic client registration before attempting
to restore from cached tokens.

This defers #3335 (persisting client credentials) to a separate PR
while still allowing token restoration to work for servers that
require client credentials.

* Revert "fix: re-register client dynamically when restoring cached tokens"

This reverts commit c82408a.

---------

Signed-off-by: Frédéric LE FEURMOU <[email protected]>
Co-authored-by: Muhammad Amir Ejaz <[email protected]>
ChrisJBurns added a commit that referenced this pull request Jun 18, 2026
- Document fail-stale-on-revocation semantics on handleAuthzConfig: a
  previously-valid ref that later becomes invalid/missing leaves an already-
  running workload enforcing its last-applied policy (fail-stale, not fail-open)
  while the MCPServer is marked Failed/Ready=False. (#2)
- Note on GenerateAuthzVolumeConfigFromRef that the mounted ConfigMap is not the
  active enforcement path in operator deployments (the proxy reads authz from the
  RunConfig-embedded config); the mount is for inline parity / future file-based
  consumption. (#3)
- Reword the status-write error messages to name the MCPServer (the object being
  written), not the MCPAuthzConfig. (#4)
- Add a transition unit test (valid -> invalid -> valid) covering the needsUpdate
  bookkeeping, plus an integration It asserting the valid -> invalid flip
  propagates to the MCPServer via the watch. (#1)
- Soften the watch test's "via the watch" phrasing to claim only the observable
  outcome. (#5)
- Tighten the unit not-found/not-valid assertions with ErrorContains. (#6)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ChrisJBurns added a commit that referenced this pull request Jun 19, 2026
* Wire MCPAuthzConfig references into the MCPServer controller

An MCPServer that sets spec.authzConfigRef now resolves and enforces the
referenced MCPAuthzConfig at runtime, mirroring the OIDCConfigRef pattern and
building on the Stage-1 controllerutil helpers. Backend-agnostic: the proxy
runner's authz factory handles cedarv1 and httpv1 alike.

- handleAuthzConfig: fetch + validate-ready, track AuthzConfigHash, set the
  AuthzConfigRefValidated condition; on nil-ref it clears the hash AND removes
  the condition so a stale "valid" signal does not linger (unlike the OIDC
  version). Wired into Reconcile after handleOIDCConfig.
- mapAuthzConfigToServers watch (extracted as a named method) + Watches on
  MCPAuthzConfig so a config change re-reconciles referencing servers.
- Runtime resolution via AddAuthzConfigRefOptions in the runconfig builder;
  ConfigMap materialization via EnsureAuthzConfigMapFromRef and a mounted volume
  via GenerateAuthzVolumeConfigFromRef. Inline spec.authzConfig is untouched and
  remains mutually exclusive (CRD XValidation).
- Add the mcpauthzconfigs get;list;watch RBAC marker.
- Unit tests for handleAuthzConfig and an envtest integration suite proving both
  backends, the watch re-reconcile, ConfigMap materialization, and the invalid
  case.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Guard ref authz volume against duplicate volume name

Belt-and-suspenders for review feedback: only add the spec.authzConfigRef
volume when the inline authz volume was not added. Inline and ref share the
"authz-config" volume name and are mutually exclusive via CRD XValidation, so a
hypothetical CEL regression now degrades to "inline wins" rather than producing
an invalid pod spec with a duplicate volume name.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Address review feedback on MCPServer authz wiring

- Document fail-stale-on-revocation semantics on handleAuthzConfig: a
  previously-valid ref that later becomes invalid/missing leaves an already-
  running workload enforcing its last-applied policy (fail-stale, not fail-open)
  while the MCPServer is marked Failed/Ready=False. (#2)
- Note on GenerateAuthzVolumeConfigFromRef that the mounted ConfigMap is not the
  active enforcement path in operator deployments (the proxy reads authz from the
  RunConfig-embedded config); the mount is for inline parity / future file-based
  consumption. (#3)
- Reword the status-write error messages to name the MCPServer (the object being
  written), not the MCPAuthzConfig. (#4)
- Add a transition unit test (valid -> invalid -> valid) covering the needsUpdate
  bookkeeping, plus an integration It asserting the valid -> invalid flip
  propagates to the MCPServer via the watch. (#1)
- Soften the watch test's "via the watch" phrasing to claim only the observable
  outcome. (#5)
- Tighten the unit not-found/not-valid assertions with ErrorContains. (#6)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
tgrunnagle added a commit that referenced this pull request Jul 3, 2026
Addresses #5672 review comment #3 (tests):
- Extract SyncRegistry's per-workload conversion+upsert loop into
  seedRegistryFromDiscoverer and unit-test it (k8s/seed_registry_test.go)
  with a mock discoverer: list-error-is-fatal, empty group, happy-path count,
  skip-on-conversion-error, and skip-nil-backend. This is the PR's "extra
  scrutiny" seam — previously exercised only by the operator E2E.
- Rename TestNewKubernetesBackendRegistry_StartsEmpty →
  ..._ReturnsRegistryAndWatcher and fix its comment: the constructor now seeds
  synchronously, so the empty result reflects an unreachable fake API, not a
  by-design empty start.
- Add TestValidator_RejectsBackendsWithDiscoveredSource for the new cross-field
  rule.
- Add TestDeriveHealthMonitorConfig covering the disabled and happy paths
  (default and explicit timeout + circuit breaker).
- Rename TestBuildCore_SharedCollaboratorBuiltOnce →
  ..._InjectedRegistryUsedByBothBuilds so it no longer over-claims single
  construction (which is the Builder's guarantee, covered there).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@tgrunnagle tgrunnagle mentioned this pull request Jul 3, 2026
4 tasks done
tgrunnagle added a commit that referenced this pull request Jul 5, 2026
Addresses #5672 review comment #3 (tests):
- Extract SyncRegistry's per-workload conversion+upsert loop into
  seedRegistryFromDiscoverer and unit-test it (k8s/seed_registry_test.go)
  with a mock discoverer: list-error-is-fatal, empty group, happy-path count,
  skip-on-conversion-error, and skip-nil-backend. This is the PR's "extra
  scrutiny" seam — previously exercised only by the operator E2E.
- Rename TestNewKubernetesBackendRegistry_StartsEmpty →
  ..._ReturnsRegistryAndWatcher and fix its comment: the constructor now seeds
  synchronously, so the empty result reflects an unreachable fake API, not a
  by-design empty start.
- Add TestValidator_RejectsBackendsWithDiscoveredSource for the new cross-field
  rule.
- Add TestDeriveHealthMonitorConfig covering the disabled and happy paths
  (default and explicit timeout + circuit breaker).
- Rename TestBuildCore_SharedCollaboratorBuiltOnce →
  ..._InjectedRegistryUsedByBothBuilds so it no longer over-claims single
  construction (which is the Builder's guarantee, covered there).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@jhrozek jhrozek mentioned this pull request Sep 7, 2026
3 tasks done
@jhrozek jhrozek mentioned this pull request Sep 25, 2026
3 tasks done
tgrunnagle added a commit that referenced this pull request Nov 19, 2026
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]>
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant