Skip to content

feat(oauth): HTTP endpoints for browser login (Spec 132 PR-1e) - #2017

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

Dumbris merged 32 commits into
mainfrom
feat/client-oauth-login-http

Conversation

@Dumbris

@Dumbris Dumbris commented Nov 23, 2026

Copy link
Copy Markdown
Member

Summary

Fifth slice of Spec 132 (opt-in browser login for MCP clients; earlier slices #1997, #2010, #2012, #2013). This one serves the feature over HTTP. It is still off by default (mcp_oauth_enabled), and while off and never used every existing answer is unchanged.

  • OAuth endpoints: protected-resource and authorization-server metadata, POST /oauth/register, GET /oauth/authorize, POST /oauth/token, and the MCP endpoints /mcp/oauth and /mcp/oauth/<client-id>.
  • Every request on an OAuth address is authenticated; open streams end when the login is revoked or the feature is switched off.
  • Loopback only, personal edition only; cross-site and forwarded requests are refused.
  • Admin REST for sign-in requests (/api/v1/oauth/authorizations/…) and logins on clients. No consent page yet (next slice): GET /oauth/authorize redirects to /ui/authorize?request=<id>.
  • Activity rows carry credential kind oauth.
  • No new dependencies.

Review

Cross-reviewed with opencode github-copilot/gpt-6.1-sol (five rounds, clean) and an Opus security review.

Testing

go test -race ./internal/server/... ./internal/httpapi/... -run 'OAuth|Oauth' (and with -tags server).

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
…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
@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: bc5ae6f
Status: ✅  Deploy successful!
Preview URL: https://af10a6fc.mcpproxy-docs.pages.dev
Branch Preview URL: https://feat-client-oauth-login-http.mcpproxy-docs.pages.dev

View logs

Comment thread internal/server/oauth_login_http.go Dismissed
…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
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

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

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-goIWCMMA.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 45239720806 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@codecov-commenter

Copy link
Copy Markdown

@Dumbris
Dumbris merged commit b1b265f into main Nov 23, 2026
82 of 85 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.

3 participants