Repository navigation
OAuth protected-resource discovery (RFC 9728) - #1055
Conversation
8ca3ddc to
ee9fc69
Compare
JAORMX
left a comment
There was a problem hiding this comment.
I went back through the full repair series rather than treating the latest commit as a fresh review. The earlier fixes around exact resource/issuer matching, redirect refusal, public-only dialing, scope comma-smuggling, confirmation ordering, registry locking, CORS composition, and independent timeouts are real improvements. Two blocking issues remain, though: discovery invents scopes when the server confirms none, and enrollment can delete a credential still referenced by a concurrently moved resource alias.
There are also two concrete accepted-but-unusable configuration paths called out inline. Before the next pass, please also route Identity.Canonical scope checks through resourceurl.ValidScopeToken; the manual login path still uses the weaker generic Safe check.
The regression suite is broad, but it still needs barrier-controlled coverage for the credential race. The concrete bootstrap client is also only tested by calling its redirect/dial components separately; an end-to-end redirect response and a resolver/dial rebinding test would make that security contract much harder to regress.
Current CI is not green: gci rejects the extra blank line at cmd/mecatui/resource_discovery.go:179, and the race shard also hit what looks like an unrelated affinity-test failure (StreamSessionLive returned EOF instead of DeadlineExceeded).
| if len(requested) == 0 { | ||
| return nil, errDiscoveryRejected | ||
| } | ||
| } else if len(requested) == 0 { |
There was a problem hiding this comment.
Blocking: the ADR says discovery must request only the confirmed set (or an explicit subset), never implicit defaults. When scopes_supported is absent, this branch invents openid,profile,offline_access; the membership check below is also disabled because confirmed is empty, so an arbitrary explicit --scopes value is accepted. An absent advertised set is valid metadata, but it is not authorization to manufacture a scope set. Preserve the empty confirmed set, and reject any explicit non-empty subset when there is nothing to prove membership against.
| current = append(current, conn) | ||
| continue | ||
| } | ||
| if resource != "" && conn.ResourceURL == resource { |
There was a problem hiding this comment.
Blocking: this removes a same-resource competitor without CAS-checking that it is still the row captured by enrollmentSnapshot. A move of target T from resource R to S locks S+T, while a concurrent enrollment of R to target U locks R+U, so the operations do not share a lock. The R→U enrollment can snapshot T's old credential, T can commit S→T, then this commit succeeds and the cleanup in Enroll deletes T's credential even though S→T now references it. Compare the complete displaced set (target rows plus same-resource rows) with the snapshot before writing, and pin this interleaving with a barrier-controlled test.
| if u.Path == "/" { | ||
| u.Path, u.RawPath = "", "" | ||
| } | ||
| return u.String(), nil |
There was a problem hiding this comment.
This accepts dot-segment paths such as https://api.example/a/../b. MetadataURL retains those segments, but the outer http.ServeMux canonicalizes the request path by redirecting it; the discovery client correctly rejects every redirect. The result is a profile accepted at startup whose metadata cannot be discovered. Reject non-canonical path forms here (including encoded dot segments), then exercise the URL through the real outer mux.
There was a problem hiding this comment.
Additional confirmed manifestations of the same AC6.1 Helm/Go validation drift: the chart also renders successfully for oidc.resource=https://:443/mcp, https://api.example.com:99999/mcp, and https://api.example.com:abc/mcp, plus a complete profile with oidc.issuer=http://idp.example.com. The binary rejects each before serving (resource hostname/port validation; HTTPS-only issuer for a protected-resource profile), but the accepted Deployment forwards the values and the pod fails at startup. Please make Helm reject these invalid authorities and the non-HTTPS issuer too, with chart coverage, alongside the literal and percent-encoded dot-segment cases already identified.
There was a problem hiding this comment.
The same Helm/Go validation drift also accepts Unicode format characters. For example, oidc.resource=https://api.example.com/mcp renders because the helper's resource regex permits U+200B, but resourceurl.Safe rejects it before the binary starts. AC6.1 requires malformed profile values to be rejected at Helm rendering. Please cover Unicode Cf alongside the literal/escaped dot segments and invalid authorities, or centralize an equivalent bounded runtime-parity validator in the chart tests.
There was a problem hiding this comment.
The new checks close the reported ASCII-control and length cases, but the Helm/runtime parity blocker remains: resourceurl.Safe rejects all Unicode controls (unicode.IsControl), while the chart only rejects \x00-\x1f and \x7f. A resource containing U+0085 (NEL) still renders successfully, then is rejected by mecak8s at startup. Please validate the full Unicode control set (and add this regression case) so AC6.1 parity is complete.
|
|
||
| // ValidateOIDCProfile validates the optional profile before listeners start. | ||
| func (c *OIDCConfig) ValidateOIDCProfile() error { //nolint:gocyclo // validation keeps the mutually-exclusive configuration matrix explicit. | ||
| if c.Resource == "" && c.ClientID == "" && c.ScopesCSV == "" && !c.scopesSet { |
There was a problem hiding this comment.
An explicitly supplied empty --oidc-resource= or --oidc-client-id= is indistinguishable here from omission, so the profile is silently treated as disabled. The acceptance contract distinguishes parser omission from a supplied empty field and requires supplied profile fields to fail before listeners start. Track resourceSet/clientIDSet the same way scopesSet is tracked, and reject explicit empties.
ee9fc69 to
7641ef5
Compare
JAORMX
left a comment
There was a problem hiding this comment.
The two earlier blocking issues are fixed at 7641ef5: discovery preserves an empty advertised scope set and rejects non-confirmed explicit scopes; enrollment now snapshots and CAS-checks the complete displaced set before deleting superseded credentials. The dot-segment and explicit-empty-flag fixes are also present.
One merge blocker remains: CI Analysis fails on the newly added test (cmd/mecatui/shorthand_enrollment_test.go:188, staticcheck S1009). Please remove the redundant nil check so the required lint gate is green. The cancelled kind e2e is not a failure, and all completed build, test, vet, docs, vulnerability, and performance checks passed.
JAORMX
left a comment
There was a problem hiding this comment.
All substantive review blockers are resolved at 7641ef5f: the discovered-scope behavior now preserves the confirmed set, the concurrent credential cleanup race is CAS-protected, dot-segment resource paths are rejected, and explicit-empty OIDC profile flags are validated.
Approving with the remaining staticcheck failure explicitly left to the author as a mechanical CI fix. The cancelled kind job is not treated as a code-review blocker.
7641ef5 to
30d4772
Compare
JAORMX
left a comment
There was a problem hiding this comment.
Re-approving after the rebase to 30d47725. Independent delta review found no OAuth regression or new source blocker; the previously resolved scope, credential-race, dot-segment, and explicit-empty fixes remain intact.
CI is still running. Any remaining mechanical CI cleanup is left to the author, consistent with the prior approval.
JAORMX
left a comment
There was a problem hiding this comment.
A new source blocker remains.
deploy/helm/mecak8s/templates/_helpers.tpl:64-68 accepts oidc.resource=https://api.example.com/a/../b (and does not reject encoded dot-segment forms), while the deployed binary rejects dot segments in internal/adapter/resourceurl/resourceurl.go:45-47 through ValidateOIDCProfile. The Deployment nevertheless forwards the accepted value as --oidc-resource (deploy/helm/mecak8s/templates/deployment.yaml:158-160), so Helm reports a successful release whose pod fails during startup.
This violates AC6.1's requirement that Helm reject malformed protected-resource profile values and mirror Go-side validation. Please make the chart reject literal and percent-encoded dot-segment paths, and add chart coverage for both forms.
The previously reviewed discovery scope, credential-CAS, resource dot-segment, and explicit-empty-flag fixes remain intact.
| return errors.New("login: a positive --callback-timeout is required") | ||
| } | ||
|
|
||
| explicitIdentity := issuer != "" || clientID != "" || audience != "" |
There was a problem hiding this comment.
Blocking: an explicitly supplied empty identity flag silently changes this invocation from explicit enrollment to untrusted protected-resource discovery. For example, mecatui login https://resource.example --issuer= reaches runDiscoveredRemoteLogin, allowing resource metadata to choose issuer, client ID, and audience rather than rejecting the incomplete explicit tuple. Presence must be tracked for all three identity flags, and explicit empties must fail before discovery/browser/persistence.
| } | ||
| resource, err := resourceurl.Canonical(c.Resource) | ||
| if err != nil || resource == "" { | ||
| return fmt.Errorf("%w: --oidc-resource must be an absolute HTTPS URL without credentials, query, or fragment", ErrOIDCMisconfigured) |
There was a problem hiding this comment.
Blocking: the server accepts and publishes a protected-resource --oidc-client-id that the discovery client subsequently rejects. A printable value longer than 1024 bytes passes this profile validation, but safeDiscoveredEnrollment rejects it through safeDisplayValue, leaving the chart/server deployment healthy-looking but impossible to enroll against. Validate the shared profile/client-ID safety contract before listeners start (or otherwise make the client accept every profile value the server advertises), with an end-to-end boundary test.
JAORMX
left a comment
There was a problem hiding this comment.
New qualifying source blockers remain at 30d47725:
mecatui logintreats explicitly supplied empty--issuer,--client-id, or--audienceas omission and switches to discovery, allowing resource metadata to select the identity tuple instead of rejecting incomplete explicit input.- The server accepts and advertises a protected-resource client ID that the discovery client rejects at the 1024-byte display-safety boundary, producing an enrollment-incompatible deployment.
- The existing AC6.1 Helm/runtime validation blocker remains; I added the independently verified Unicode-format-character manifestation to its existing thread, without duplicating the existing dot-segment, authority, and issuer cases.
All completed required checks are green. k8s e2e (kind) is cancelled; this mechanical CI status is not a source-review blocker.
0ad1b50 to
bced9ee
Compare
JAORMX
left a comment
There was a problem hiding this comment.
I re-reviewed the current head bced9ee5 from a detached worktree and confirmed the earlier substantive fixes are present: no invented scopes, complete displaced-set CAS before credential cleanup, explicit-empty identity rejection, client-ID bounds, and the originally reported Helm cases.
One source blocker remains: the Helm validator is still not runtime-parity complete. It accepts malformed profiles that resourceurl.Canonical / ValidateOIDCProfile reject, so Helm successfully deploys a pod that exits on startup. Confirmed examples include https://api.example.com/a/%2e%2e%2fb (an encoded separator exposes a .. segment after decoding), https://[::1]:99999/mcp, and oidc.issuer=https:///issuer. Please extend deploy/helm/mecak8s/templates/_helpers.tpl:62-71 and TestADR_0302_HelmProtectedResourceProfile to cover complete URL/issuer validation rather than only the currently enumerated forms. This is an AC6.1 correctness requirement, not a CI-only concern.
Separately, the current Docs and k8s-e2e CI failures are not the basis for this review decision: Docs reports the ADR-0302 collision on the merge ref; k8s-e2e stops because GOWORK=off needs a tidy module graph.
JAORMX
left a comment
There was a problem hiding this comment.
A new delta regression blocks approval.
queryInternal starts a run, then checks signal before it constructs QueryImpl (sdk/typescript/src/query.ts:228-242). If the signal aborts in that window, the catch path calls unwindSetup, which deletes the session but never cancels or drains the already-started run (sdk/typescript/src/query.ts:61-77). Session.delete() is only the DeleteSession unary RPC (sdk/typescript/src/client.ts:411-413); it does not cancel the Converse stream. With a caller-supplied client the client is intentionally left open, so the model/tool run can continue after query() rejects.
That contradicts the documented signal contract to “abort this query and clean up every resource it created,” and can leave unintended execution active (while the delete can race/fail against that active run). Please retain the returned Run for setup unwinding and cancel/drain it before deleting the session, with a regression test that aborts immediately after session.run() resolves.
The prior Helm runtime-parity blocker is fixed at this head: the chart now rejects the invalid protected-resource/issuer forms and has matching chart coverage. This review concerns only the newly added TypeScript query delta.
JAORMX
left a comment
There was a problem hiding this comment.
Re-approving at bced9ee5. The prior changes-request review incorrectly attributed sdk/typescript/src/query.ts to this PR after the branch/base moved; that file is not in PR #1055’s merge-base diff and is therefore out of scope here.
The actual OAuth delta fixes the remaining Helm/runtime validation mismatch, and all previously reviewed blockers remain resolved. Remaining CI/merge-ref issues are left to the author as mechanical integration work.
bced9ee to
9aaf6ea
Compare
JAORMX
left a comment
There was a problem hiding this comment.
Current PR merge-base diff review at 9aaf6eab5 found two in-scope merge blockers. I verified both affected paths are present in the current PR file list; this review does not rely on a raw old-head comparison.
-
Stale discovered login can resurrect a logged-out credential —
cmd/mecatui/login.go:172-174, viarunSavedRemoteLoginWithatcmd/mecatui/login.go:390-391.The discovered-login route invokes the ordinary preparation path, which supplies neither
ExpectedTargetnorExpectedCredentialtoclientauth.Enroll. If a resource already has an enrollment, an interactive discovered login can start, a concurrent logout can remove that enrollment while browser authorization is pending, and completion can then re-create the removed row/credential. The existing reauthentication path avoids this by snapshotting the target and credential before the browser wait and passing both CAS expectations toEnroll; the new discovered route needs the same stale-state protection (or an equivalent CAS contract), with an interleaving regression test. -
Helm accepts protected-resource values the binary rejects —
deploy/helm/mecak8s/templates/_helpers.tpl:65-76(and no schema equivalent atdeploy/helm/mecak8s/values.schema.json:46-48).Runtime validates both resource and client ID through
resourceurl.Safe(internal/cliconfig/oidc.go:226-231), which rejects values longer than 1024 bytes and all Unicode control characters. The chart bounds onlyclientIDand only rejects ASCII controls there; it does not apply the corresponding bounded/control validation toresource. Therefore a Helm release can render successfully while mecak8s exits during startup. This violates the stated Helm/runtime validation-parity requirement. Please make chart validation reject the same bounded/control-invalid resource/client-ID cases and add matching chart tests.
All other required CI checks are green. The failing k8s e2e (kind) check is reported separately and is not the basis of this review.
26646fd to
6047ebb
Compare
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: GPT-5.6 Terra <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: OpenAI <[email protected]>
Co-Authored-By: OpenAI <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
…char parity The discovered-login route reused prepareSavedRemoteLogin, which returned no ExpectedTarget/ExpectedCredential snapshot at all, so a concurrent logout racing the interactive browser wait could be silently undone by Enroll. prepareSavedRemoteLogin now shares the same preflight snapshot as the existing reauthentication path, closing the gap for both callers. The Helm chart's oidc.resource validation was missing the length and ASCII control-character bounds that internal/cliconfig already enforces on the runtime side via resourceurl.Safe (already applied to clientID), so a Helm release could render successfully while mecak8s rejected the same value at startup. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…entID resourceurl.Safe rejects every rune where unicode.IsControl is true, which covers C0 (0x00-0x1f, 0x7f) AND C1 (0x80-0x9f) controls -- e.g. U+0085 (NEL). The chart's regex only excluded C0, so a resource or clientID containing a C1 control still rendered successfully and was then rejected by mecak8s at startup, breaking the documented Helm/runtime parity. Co-Authored-By: Claude Sonnet 5 <[email protected]>
docs/adr/0304-typescript-sdk-public-surface-and-release.md landed on main with the same number this branch had claimed. Renumber ours to the next free slot and update every cross-reference (test names, acceptance plan, doc links). Co-Authored-By: Claude Sonnet 5 <[email protected]>
docs/adr/0304-typescript-sdk-public-surface-and-release.md landed on main with the same number this branch had claimed. Update every cross-reference to the renumbered ADR (test names, acceptance plan, doc links). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
6047ebb to
e2b7193
Compare
JAORMX
left a comment
There was a problem hiding this comment.
The remaining Helm/runtime parity blocker is fixed at e2b7193272ee542d55f25c3f0a6ffe166f7004ed: the chart rejects C1 controls through \x7f-\x9f, and TestADR_0305_HelmProtectedResourceProfile adds the U+0085 regression case. I found no regression in the changed blocker hunk.
All required checks are green, including k8s e2e (kind). The existing threads have no new replies and remain unresolved; they are historical tracking items, not remaining blockers.
… never joined appendAuthorizationResolution continued past an ambiguous per-event Append failure to avoid stranding later events, but still appended EvAuthorizationResolved even when the PRIMARY call's own EvToolResult was the one that failed. If that failure meant the result genuinely never committed, Fold's resolveAuthorization hard-rejects the log (ErrReconstruct) instead of the intended soft "still open" outcome (ErrPrivateStateRequired) the design already has for genuine ambiguity. Skip the resolved append whenever the primary result's own append fails, folding both the post-write-ambiguous and genuinely-uncommitted cases into the same safe behavior, since a caller of port.EventLog.Append cannot tell them apart. Also extends the ToolHive import boundary allowlist with the two RFC 9728 protected-resource-discovery files (#1055) that legitimately import oauthproto from a separate, unrelated ToolHive integration than this branch's own MCP broker leaves. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… never joined appendAuthorizationResolution continued past an ambiguous per-event Append failure to avoid stranding later events, but still appended EvAuthorizationResolved even when the PRIMARY call's own EvToolResult was the one that failed. If that failure meant the result genuinely never committed, Fold's resolveAuthorization hard-rejects the log (ErrReconstruct) instead of the intended soft "still open" outcome (ErrPrivateStateRequired) the design already has for genuine ambiguity. Skip the resolved append whenever the primary result's own append fails, folding both the post-write-ambiguous and genuinely-uncommitted cases into the same safe behavior, since a caller of port.EventLog.Append cannot tell them apart. Also extends the ToolHive import boundary allowlist with the two RFC 9728 protected-resource-discovery files (#1055) that legitimately import oauthproto from a separate, unrelated ToolHive integration than this branch's own MCP broker leaves. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… never joined appendAuthorizationResolution continued past an ambiguous per-event Append failure to avoid stranding later events, but still appended EvAuthorizationResolved even when the PRIMARY call's own EvToolResult was the one that failed. If that failure meant the result genuinely never committed, Fold's resolveAuthorization hard-rejects the log (ErrReconstruct) instead of the intended soft "still open" outcome (ErrPrivateStateRequired) the design already has for genuine ambiguity. Skip the resolved append whenever the primary result's own append fails, folding both the post-write-ambiguous and genuinely-uncommitted cases into the same safe behavior, since a caller of port.EventLog.Append cannot tell them apart. Also extends the ToolHive import boundary allowlist with the two RFC 9728 protected-resource-discovery files (#1055) that legitimately import oauthproto from a separate, unrelated ToolHive integration than this branch's own MCP broker leaves. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… never joined appendAuthorizationResolution continued past an ambiguous per-event Append failure to avoid stranding later events, but still appended EvAuthorizationResolved even when the PRIMARY call's own EvToolResult was the one that failed. If that failure meant the result genuinely never committed, Fold's resolveAuthorization hard-rejects the log (ErrReconstruct) instead of the intended soft "still open" outcome (ErrPrivateStateRequired) the design already has for genuine ambiguity. Skip the resolved append whenever the primary result's own append fails, folding both the post-write-ambiguous and genuinely-uncommitted cases into the same safe behavior, since a caller of port.EventLog.Append cannot tell them apart. Also extends the ToolHive import boundary allowlist with the two RFC 9728 protected-resource-discovery files (#1055) that legitimately import oauthproto from a separate, unrelated ToolHive integration than this branch's own MCP broker leaves. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… never joined appendAuthorizationResolution continued past an ambiguous per-event Append failure to avoid stranding later events, but still appended EvAuthorizationResolved even when the PRIMARY call's own EvToolResult was the one that failed. If that failure meant the result genuinely never committed, Fold's resolveAuthorization hard-rejects the log (ErrReconstruct) instead of the intended soft "still open" outcome (ErrPrivateStateRequired) the design already has for genuine ambiguity. Skip the resolved append whenever the primary result's own append fails, folding both the post-write-ambiguous and genuinely-uncommitted cases into the same safe behavior, since a caller of port.EventLog.Append cannot tell them apart. Also extends the ToolHive import boundary allowlist with the two RFC 9728 protected-resource-discovery files (#1055) that legitimately import oauthproto from a separate, unrelated ToolHive integration than this branch's own MCP broker leaves. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… never joined appendAuthorizationResolution continued past an ambiguous per-event Append failure to avoid stranding later events, but still appended EvAuthorizationResolved even when the PRIMARY call's own EvToolResult was the one that failed. If that failure meant the result genuinely never committed, Fold's resolveAuthorization hard-rejects the log (ErrReconstruct) instead of the intended soft "still open" outcome (ErrPrivateStateRequired) the design already has for genuine ambiguity. Skip the resolved append whenever the primary result's own append fails, folding both the post-write-ambiguous and genuinely-uncommitted cases into the same safe behavior, since a caller of port.EventLog.Append cannot tell them apart. Also extends the ToolHive import boundary allowlist with the two RFC 9728 protected-resource-discovery files (#1055) that legitimately import oauthproto from a separate, unrelated ToolHive integration than this branch's own MCP broker leaves. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… never joined appendAuthorizationResolution continued past an ambiguous per-event Append failure to avoid stranding later events, but still appended EvAuthorizationResolved even when the PRIMARY call's own EvToolResult was the one that failed. If that failure meant the result genuinely never committed, Fold's resolveAuthorization hard-rejects the log (ErrReconstruct) instead of the intended soft "still open" outcome (ErrPrivateStateRequired) the design already has for genuine ambiguity. Skip the resolved append whenever the primary result's own append fails, folding both the post-write-ambiguous and genuinely-uncommitted cases into the same safe behavior, since a caller of port.EventLog.Append cannot tell them apart. Also extends the ToolHive import boundary allowlist with the two RFC 9728 protected-resource-discovery files (#1055) that legitimately import oauthproto from a separate, unrelated ToolHive integration than this branch's own MCP broker leaves. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Summary
See the contribution guide for contribution and verification expectations.
Why:
mecatui loginpreviously required an operator to hand-configure--issuer/--client-id/--audiencefor every remote resource before it could authenticate. This adds RFC 9728 (OAuth 2.0 Protected Resource Metadata) discovery somecatui login HOSTNAME(or an explicit HTTPS resource URL) can discover that identity automatically, with the resource server publishing it anonymously at/.well-known/oauth-protected-resource.What changed:
mecated/mecak8sserve an anonymous RFC 9728 metadata endpoint derived from the server's OIDC profile (internal/adapter/server/protected_resource.go), mounted under the existing exact-origin CORS policy.mecatui logingains hardened client-side discovery (cmd/mecatui/resource_discovery.go): anonymous, redirect-free, DNS-rebinding-resistant (viatoolhive-core/networking's private-IP dial guard), bounded, with duplicate-JSON-key rejection, exact resource/issuer matching, and human confirmation before any browser launch or credential persistence.internal/adapter/clientauth) gains an optional resource-URL alias alongside the existing target-keyed credential identity, so a discovered resource can be looked up by either.--grpc-targetlets an operator separate the RFC 9728 resource identity (always HTTPS) from the actual gRPC transport target, for split ingress/gateway deployments.deploy/helm/mecak8s) gains the matchingoidc.resource/oidc.clientID/oidc.scopesvalues and template wiring, with fail-fast validation mirroring the Go-side checks.Fixes #
Type of change
Test plan
Required baseline
task lint) — not run locally; CI gates thistask test) — full suite green, 180 packages, 0 failuresgo run ./cmd/mecademo) — verifiedConditional checks
task docs)task site:build)Changes
internal/adapter/server/protected_resource.gointernal/adapter/resourceurl/cmd/mecatui/resource_discovery.gocmd/mecatui/login.go--grpc-targetinternal/adapter/clientauth/store.gointernal/cliconfig/oidc.godeploy/helm/mecak8s/oidc.resource/oidc.clientID/oidc.scopesvalues + template wiringdocs/adr/0290-oauth-protected-resource-discovery.mddocs/acceptance/oauth-protected-resource-discovery.mdDoes this introduce a user-facing change?
Yes:
mecatui logincan now discover OAuth identity automatically from a resource server implementing RFC 9728, instead of requiring--issuer/--client-id/--audienceup front. Existing explicithost:port+ explicit-flag logins remain fully compatible.Special notes for reviewers
This PR went through a full multi-agent review pass (OAuth/security, Go code quality, architecture, Helm/K8s) plus a manual walkthrough. Findings addressed in the last commit:
resourceurl.ValidScopeToken— closes a comma-smuggling gap reachable from untrusted discovery metadata.[y/N]confirmation prompt mishandled a bare Enter (the natural "no") as a hard error; replacedfmt.Fscanlnwith abufioline read.buildAPIHandler.toolhive-core/networking.NewPrivateIPBlockingDialContext()— removes ~40 lines and closes CGNAT/6to4/Teredo/TEST-NET gaps the hand-rolled version didn't cover.values.yamlsurface.Deliberately NOT reused from ToolHive despite adjacent upstream code existing:
pkg/auth.NewAuthInfoHandler(wildcard CORS, incompatible JSON shape) andpkg/auth/discovery.FetchResourceMetadata(follows same-host redirects, has an SSRF opt-out this design forbids, and its own comment admits resource-identity matching is "just check it's not empty" rather than exact) — both would have been regressions relative to what's implemented here.