Skip to content

feat(oauth): consent page with client name suggestion for browser login (Spec 132 PR-2a) - #2020

Merged
Dumbris merged 56 commits into
mainfrom
feat/client-oauth-login-consent
Nov 23, 2026
Merged

Dumbris merged 56 commits into
mainfrom
feat/client-oauth-login-consent

Conversation

@Dumbris

@Dumbris Dumbris commented Nov 23, 2026

Copy link
Copy Markdown
Member

Summary

Spec 132 PR-2a: the Web UI consent page for opt-in browser login (mcp_oauth_enabled, default off). Nothing changes while the switch is off.

  • /ui/authorize (AuthorizeRequest.vue): shows who is asking (registration name and redirect host, in <bdi>), lets the user pick an existing client or create one, and a profile; approve or deny. A client that is already bound shows its profile instead of asking. Without an API key in the page it explains how to open the page from the tray or CLI.
  • Name suggestion on the generic address /mcp/oauth (FR-013/FR-014, from the feedback in Act as an OAuth authorization server for MCP clients (DCR) instead of per-client API keys #1971): the reported client name is compared (trimmed, case-insensitive, whole name and name without one trailing parenthesised group) with each existing client's id, display name and known client names. Exactly one match pre-selects that client as suggested_client {id, matched}; the server never applies it by itself. Preview without a client answers 200 {complete:false}; approve without one answers 422 client_required.
  • Names from the wire lose Unicode format characters (mcplogin.StripFormat) on registration, new-client display name and the observed initialize name.
  • previous_logins per client with client_id, 422 invalid_replace_grant, inline 404 client_not_found.
  • Frame headers on /ui/authorize (path cleaned, case-insensitive).
  • Docs: docs/features/client-oauth-login.md, docs/api/rest-api.md.

No new dependencies.

Testing

  • go test ./internal/mcplogin/... ./internal/runtime/ ./internal/httpapi/
  • npx vitest run: 340 files, 3042 tests pass
  • golangci-lint v2 with .github/.golangci.yml on the new code: 0 issues
  • Playwright spec e2e/web-ui-sweep/client-oauth-consent.spec.ts; the page was also driven by hand in Chromium against a scratch core.
  • Cross-model review: 8 rounds with gpt-6.1-sol until clean, plus one security review.

Related #1971

…PR-1e)

Public OAuth endpoints behind the three-state gate (metadata, register,
authorize, token), the /mcp/oauth[/<client>] resource chain that
authenticates mcp_oat_ tokens on every request, the mcp_oat_ refusal on the
classic MCP routes, admin REST for sign-in requests, per-login and API-key
revoke, credentials[] on client payloads, and the oauth credential kind on
activity rows.

Related #1971
…Spec 132 PR-1e)

Register takes exactly one JSON object as application/json; mcp_oat_ is
refused on classic MCP routes whatever the bearer whitespace and on the REST
API with the client-credential 403; once used every client row carries
credentials and browser_login_disabled (install-wide); open requests and SSE
streams end with their login (revoke, forget, switch-off, rotation, expiry);
cross-origin and cross-site posts to register and token are refused; an
unreadable ever-used marker reads as used; OAuth routes answer 404 behind a
proxy header.

Related #1971
… (Spec 132 PR-1e)

Cancelling a tracked request also sets immediate read and write deadlines so
a handler blocked in a write or a body read ends; the watcher is stopped and
joined at shutdown (also in StopServer). A monotonic switch-off epoch makes a
quick off then on still end requests authenticated before it. Tests cover
blocked write, stalled upload, shutdown, quick off/on, and client revoke,
client forget and refresh-token replay ending only the affected stream.

Related #1971
…2 PR-1e)

The switch-off epoch is counted when the disabled configuration is published,
so a request that authenticated under the enabled one is always older than
it. Stream tracking has a stopping flag checked under the mutex that creates
the registry, and a fresh lifecycle per server run; a refused request is
answered 503 without invoking the MCP handler.

Related #1971
… server run (Spec 132 PR-1e)

A switch-off whose publish fails no longer ends live streams: the epoch is
counted only after a successful publish while the lifecycle lock is always
released. A request captures a server-run generation before authenticating and
is refused (503, handler not invoked) if it registers in another run.

Related #1971
…er login (Spec 132 PR-1f)

scripts/test-client-oauth-e2e.sh drives a real ./mcpproxy on a scratch data dir
through default off, discovery, registration, authorize, admin approve, PKCE
exchange, MCP over the login, wrong doors, refresh and replay, revoke/forget,
guard refusal, rate limits, off after use and on again.

Also adds docs/features/client-oauth-login.md, the CLAUDE.md entry, and
specs/132-client-oauth-login/verification/real-clients.md (SDK client verified;
Claude Code, Cursor, VS Code and Inspector not verified).

Related #1971
Web UI consent page at /ui/authorize for browser sign-in requests, with
the generic-address name suggestion.

- suggested_client on GET /api/v1/oauth/authorizations/{id} (generic
  address only): the sanitised reported name, trimmed and case-insensitive,
  compared with each existing client's id, display name and known client
  names (whole name, and the part before a trailing parenthesised suffix);
  exactly one distinct client -> {id, matched}, none or several -> absent.
  Computed on read, never stored, never applied by the server: preview
  without a client answers complete:false, approve answers client_required.
- Content-Security-Policy frame-ancestors 'none' and X-Frame-Options DENY
  on /ui/authorize.
- AuthorizeRequest.vue, /authorize route, API methods and types: fixed or
  chosen client, unverified-name label, access sentence, profile shown or
  asked, replace-login checkbox, guard verdict through preview with fixes,
  no-API-key mode, already_decided / binding_changed / 404 handling.
- Docs: REST reference and docs/features/client-oauth-login.md.

Related #1971
- /ui/authorize frame headers: case-insensitive on the cleaned path
  (Vue Router matches case-insensitively and the SPA answers unknown paths).
- suggested_client: compare with strings.EqualFold (Unicode folding), strip
  one balanced trailing parenthesised group (nested parentheses allowed);
  tests for display-name-only, display name over known name, sigma forms,
  nested suffix and whole-name vs stripped-name ambiguity.

Related #1971
…Spec 132 PR-2a)

- Page: a new ?request= id clears the page and reloads (generation check);
  decisions go to the loaded request. Approve needs a complete preview with
  access for the current choice and sends exactly the body it answered.
  The replace-login option is tied to the client that owns the previous
  login. The new-client draft is always filled from suggested_new_client.
  One decision per page: both buttons guarded, terminal after success.
- Backend: previous_login carries client_id; a replace_grant that is a live
  login of this registration owned by another client is refused (422,
  field replace_grant).

Related #1971
- Decision answers are ignored once the request was left (new id) or the
  page unmounted: no navigation, no state change, no release of a newer
  request's pending decision.
- A preview refused with binding_changed reloads the request (keeping the
  user's choice when it still exists) and shows the review-again notice.
- With no profiles configured an unbound client starts on "All servers", so
  the select shows what is submitted.

Related #1971
- A review-again reload validates every kept choice against the reloaded
  data: profile (All servers when none remain, unset when the named one is
  gone), client, lock and replace flags.
- Every choice control is disabled while a decision is pending or done.
- The review-again notice is set only when the reload's generation was
  applied, so it cannot appear on another request.

Related #1971
- Starting a decision invalidates outstanding previews; preview handlers do
  nothing while a decision is pending or done, so a late binding_changed can
  no longer drop a Deny/Approve answer. After a recoverable decision failure
  the cut-off preview is run again.
- A failed preview shows "Check again", which re-runs it for the current
  request and choice under the same guards.

Related #1971
- A preview answering binding_changed reloads the request once on its own;
  after that the page stops, shows the review-again notice, keeps Deny and
  offers "Check again". A user edit, a new request or "Check again" earns
  one more reload.
- A failed load (not a 404) shows "Try again", bound to the current request.
- The replace-flag reload test asserts unconditionally (g1 -> g2).

Related #1971
Drives /ui/authorize in a real browser against a core started with
MCPPROXY_MCP_OAUTH_ENABLED=true: per-client and generic addresses, the
name suggestion, new client, deny, no API key, markup-shaped names and the
frame headers. Skips when browser login is not served.

Related #1971
- Names a client reports lose Unicode format characters (category Cf: bidi
  overrides and isolates, zero-width, BOM) at registration and in a new
  client's display name (mcplogin.StripFormat; the shared clientidentity
  sanitiser is unchanged).
- The page renders every untrusted name (reported name in both sentences, the
  return address, the new-client name in the access sentence) in its own
  bdi element, with the page's own quotes and copy outside it.
- previous_logins: the newest live login of the registration under each
  client; the page offers Replace for the selected client.
- A 404 client_not_found is shown on the choice, not as an expired request.
- Client options show the id next to the display name.

Related #1971
…pec 132 PR-2a)

The name a browser login sends at initialize now loses Unicode format
characters before it is stored, and OAuthNameMismatch strips them before
comparing, so an app that registers and initializes under the same
Cf-containing name is not flagged and no Cf character is stored or listed.

Also fixes a time bomb in the OAuth test fixture: mintClient used the
fixture clock, which storage validates against the real clock, so every
test using it failed once the real date passed the fixture's +24h.

Related #1971
…32 PR-1d)

Storage validates expiry against the real clock, so a fixed fixture date
started failing once it passed.

Related #1971
Windows reports 0666 for any writable file.

Related #1971
…132)

The client record's position among random token hashes was left to 30
tries on one store, which fails in a few percent of runs. A store that
leaves the client first or last is now rebuilt.

Related #1971
…pec 132 PR-1e)

After StopServer and a new StartServer in one process, the context watcher
of the stopped run called StopServer once more and its exit path cleared
the running state; either could land on the new run and leave it stopped.
The watcher's stop and the exit cleanup are now bound to their own run.

Found through TestOAuthStreams_StopThenStartTracksAgain failing in CI.

Related #1971
…c 132 PR-1e)

StopServer captured the HTTP server at entry but cancelled and unmarked
whatever run was current at its end. It now cancels the context of the
run it began stopping and clears state only while that run is current.

Related #1971
CLAUDE.md reached 40,631 characters with the Spec 132 entry, over the
40,000 limit of the check-size job. Remove the seven oldest entries
(specs 108, 109, 115, 116 and 117 PR-1/PR-2); their docs pages are
unchanged.

Related #1971
…in-consent

# Conflicts:
#	docs/features/client-oauth-login.md
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6d31703
Status: ✅  Deploy successful!
Preview URL: https://dab100c8.mcpproxy-docs.pages.dev
Branch Preview URL: https://feat-client-oauth-login-cons.mcpproxy-docs.pages.dev

View logs

TestWebUISweepSpecListIsComplete requires every spec under
e2e/web-ui-sweep to be run by a launcher and named in the two docs.
The sweep core now starts with MCPPROXY_MCP_OAUTH_ENABLED=true and
run-web-smoke.sh runs client-oauth-consent.spec.ts (9 tests) with the
other specs: 136 passed, 3 skipped locally.

Related #1971
@github-actions

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: feat/client-oauth-login-consent

Available Artifacts

  • archive-darwin-amd64 (33 MB)
  • archive-darwin-arm64 (30 MB)
  • archive-linux-amd64 (21 MB)
  • archive-linux-arm64 (19 MB)
  • archive-windows-amd64 (33 MB)
  • archive-windows-arm64 (29 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (29 MB)
  • installer-dmg-darwin-arm64 (26 MB)
  • smart-mcp-proxymcpproxy-goYCQM8S.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 45283556582 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 93.67089% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/runtime/oauth_login_consent.go 92.42% 3 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@Dumbris
Dumbris merged commit df91183 into main Nov 23, 2026
55 checks passed
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