Skip to content

feat: add native LLM endpoint OIDC login - #1388

Merged
JAORMX merged 22 commits into
mainfrom
impl/native-llm-gateway-login
Sep 12, 2026
Merged

JAORMX merged 22 commits into
mainfrom
impl/native-llm-gateway-login

Conversation

@JAORMX

@JAORMX JAORMX commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Implementation

Implements the approved native LLM endpoint OIDC login contract.

Stage: Implementation

Plan / Interface PR: #1297
Plan amendment: #1335
Approved baseline: bc8d0202ed7fd6db0b202130c44b5e94ee2d4fc4

Completed

  • operator-only llm.endpoints configuration facade
  • native OIDC enrollment, encrypted credential storage, refresh, status, and logout
  • deployment-wide registry/inventory integration and confined bearer transport
  • explicit mecatui llm login|status|logout ENDPOINT UX
  • ToolHive compatibility and credential isolation
  • ADR, resource inventory, architecture, configuration, and user documentation

Interfaces match approved contract: Yes

Verification

  • task lint
  • task test
  • task docs
  • task site:build
  • task api:check
  • go run ./cmd/mecademo
  • focused race tests

The final panel's initially reported security and UX blockers were repaired in 88cced20f; subsequent reviewer invocations failed at the review infrastructure layer. The directing human explicitly instructed the workflow to continue rather than block on those infrastructure failures.

@JAORMX
JAORMX force-pushed the impl/native-llm-gateway-login branch from d263789 to f3a8e1a Compare September 11, 2026 06:31

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panel review (Spec / Standards / Test-adequacy / Domain — secure-code-reviewer, oauth-expert, go-security-reviewer, software-architect, code-duplication-reviewer, library-reuse-reviewer). No ship-blockers: encryption/CAS/identity-binding, dual-layer gateway origin confinement, PKCE/state/RFC 9207 iss/RFC 8414 discovery, refresh/rotation/invalid_grant, RFC 7009 revocation, and the secret-free error paths all checked out. Posting the 2 important and the low/informational domain findings inline below; a couple of Spec/Standards advisories are included too since they're concrete enough to act on. Full report available on request.

Comment thread internal/app/native_llm_gateway_test.go Resolved
Comment thread internal/adapter/oidcclient/keyring.go Resolved
Comment thread internal/cliconfig/native_endpoint.go Resolved
Comment thread internal/app/registry.go Resolved
@JAORMX
JAORMX force-pushed the impl/native-llm-gateway-login branch 2 times, most recently from 6395d96 to 81004fd Compare September 11, 2026 12:19
@JAORMX

JAORMX commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review. I rebased the branch onto current main and pushed the follow-up as 81004fdcc.

Addressed:

  • Added adapter-level coverage for a persistent 401 stopping after exactly one refresh/retry, non-replayable request bodies returning the original 401 without refresh/retry, and redirect refusal.
  • Made the non-replayable-body behavior explicit in the gateway transport and its exported constructor documentation.
  • Aligned NormalizeScopes with the local slices.Clone → validate → slices.Sort → slices.Compact idiom, including ownership/non-mutation coverage.

For the keyring and transaction-lock duplication observations: I reviewed a shared extraction and am deliberately not taking it in this PR. The native OIDC keyring, endpoint-identity transaction lock, and clientauth registry have distinct isolation, legacy-migration, existing-only, and root-validation contracts. They already share the appropriate generic encrypted-CAS-store seam; a common callback-heavy key/lock abstraction would couple security-sensitive lifecycles without a third equivalent use case.

The post-lock chmod(0600) remains intentionally: flock.SetPermissions(0600) covers creation, while the explicit chmod repairs a pre-existing lock file before protected state is used. The existing native-lock mode test covers that behavior.

The remaining notes are acknowledged. Same-origin discovered endpoints and the fixed loopback port are deliberate, documented hardening/operability tradeoffs; the runtime remains cohesive; the local-status tests cover separate adapter and CLI seams; and native endpoint status stays passive by design rather than emitting startup diagnostics for an endpoint that may never be selected.

JAORMX and others added 19 commits September 11, 2026 20:17
@JAORMX
JAORMX force-pushed the impl/native-llm-gateway-login branch from 7523161 to 21b4649 Compare September 11, 2026 17:21
JAORMX and others added 2 commits September 12, 2026 11:10
JSON round trips preserve expiry instants, not time.Time location identity. Compare credential fields explicitly and use Time.Equal for expiry. Force a distinct zero-offset fixture location so the regression is independent of the host timezone, and assert refresh returns the bearer only after the durable commit callback.

Co-Authored-By: mecatl <[email protected]>
@JAORMX
JAORMX merged commit 4dce3a7 into main Sep 12, 2026
34 checks passed
@JAORMX
JAORMX deleted the impl/native-llm-gateway-login branch September 12, 2026 10:25
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Sep 14, 2026
2 tasks
reyortiz3 added a commit that referenced this pull request Sep 23, 2026
Addresses the 2026-09-23 review round:

- Document the /oauth/callback redirect_uri registration requirement for
  preregistered/CIMD clients in user-docs (AGENTS.md requires this in the
  same PR as the behavior change).
- Fix a comment in cmd/mecated/mcplogin.go that referenced opts.Client.DCR
  on a local oauthlogin.Options value that has no Client field; the DCR
  field actually lives on the unrelated mcp.OAuthOptions built in
  internal/cliconfig/mcpprofile.go.
- Add TestRunMCPLoginProductionOptionsKeepDCRPriorityThroughRealRuntime: an
  app-wiring-layer test that captures the real production
  oauthlogin.Options, obtains a genuine registration-bound callback path
  from mcp.PrepareOAuthDCRLogin against a real DCR fixture, and drives both
  through a real oauthlogin.Runtime -- proving the priority holds beyond
  the isolated mcp/oauthlogin package.
- Replace the port-distinctness assertion in
  TestPinCallbackPathUsesFixedPathEphemeralPort (flaky if the OS legally
  reuses a just-released ephemeral port) with an assertion on the bind
  address requested via the injected listener seam.
- Extract assertUnauthenticatedFloodDoesNotSpendAttempts, shared by
  TestExactRedirectUnauthenticatedFloodDoesNotSpendAttempts and
  TestPinCallbackPathUnauthenticatedFloodDoesNotSpendAttempts, which had
  drifted into a near-duplicate.
- Return a callbackMode struct from resolveCallbackMode instead of five
  positional string/enum values, matching the file's existing
  fixedRedirectConfig convention and removing a silent-reorder risk.
- Extract exactRedirectAddress so "127.0.0.1:18473" has one source instead
  of three duplicated literals that must stay byte-identical.

Two other findings from the same review round were pushed back on with
reasoning posted to the PR rather than implemented:
- The "CIMD cannot work with this mode" blocker: CIMD is a public/native
  client mechanism by design and by this codebase's own config schema (no
  secret field), so RFC 8252 loopback matching applies to a CIMD-declared
  redirect_uri the same as it does to a preregistered one.
- The "needs a superseding ADR" claim: two prior PRs (#847, #1388) already
  added new fixed-callback Options fields to this exact runtime without a
  superseding ADR, establishing that this is within-mechanism extension,
  not an architectural decision.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 4d87cb24 Deployed Sep 12, 2026 by vercel[bot]
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.

2 participants