Repository navigation
fix(oauth): support OAuth sign-in from a remote Web UI - #1597
Conversation
267bbf4 to
cec2953
Compare
|
I was just going to let claude build the same. i can confirm it works with the gitlab mcp. {
"quarantined": false,
"name": "GitLab",
"url": "https://gitlab.domain.de/api/v4/mcp",
"protocol": "http",
"oauth": {
"callback_base_url": "https://mcpproxy.homelab.de"
},
"enabled": true
} |
…s browser is not the user's Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…gistered; tighten callback_base_url validation A login completed through oauth.callback_base_url stored the private loopback URI with its token, so the next connect saw a mismatch and cleared a valid DCR registration after every sign-in (cross-model review finding). Also reject out-of-range ports and malformed IPv6 literals in callback_base_url, refuse the "."/".." server names the mux would normalise away, and make a remote UI treat a daemon-host browser launch with no auth_url as an error instead of a success toast. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Thank you @tomgrin10 — this is a genuinely good piece of work: the public callback is gated on an explicitly configured origin, the single-use state dispatch is reused instead of re-implemented, unknown-state hits don't poison upstream health, and the DCR invalidation cases are thought through. The docs and the test provider coverage made it easy to verify. What I did before merging:
Three things I pushed to your branch (hope that's OK — "allow edits by maintainers" was on):
Merging once CI is green. Thanks again — this unblocks headless/Tailscale users properly. |
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Description
Fixes #1595. On a headless host, the Web UI discarded the authorization URL and said “Check your browser.” Following the URL manually then sent the callback to localhost on the user's laptop.
Open the returned authorization URL in a tab reserved during the user's click. Blocked popups get a persistent sign-in link; unsafe URL schemes are rejected and the tab has no opener.
Opt into a remote callback with an explicit HTTPS origin:
The reverse proxy must forward
/oauth/callback/<server-name>to MCPProxy's main HTTP listener. This reuses PKCE and atomic, single-use state dispatch, rejecting missing, duplicate, expired, replayed and cross-server states. Invalid public callbacks do not alter upstream health. Responses disable caching/referrer disclosure; no API key is sent to the provider, and the origin is never inferred from request headers. Loopback remains the default.DCR registrations follow the exact external redirect URI and survive changes to an unpinned private callback port. Configuration merge, validation, reconnect detection, persistence, docs and generated OpenAPI include the new setting. Static clients must register the exact HTTPS callback with a provider that permits it.
Manual account-switching/recovery controls are independent in #1599, tracked in #1598. This PR contains only the remote-browser flow.
Testing
I have tested these changes locally
I have added/updated tests that prove my fix is effective or my feature works
All existing tests pass
go test -p 2 ./internal/config ./internal/oauth ./internal/upstream/corepassed.Focused race tests passed for callback state routing, HTTPS PKCE, DCR migration, private-port changes, origin validation and redirect persistence.
Five focused server smoke/OAuth tests passed with
MCPPROXY_BINARY_PATHset to a binary built from this independent branch.Nine affected frontend tests and
npm run build(including TypeScript checking) passed. The full frontend suite previously passed on the remote-login implementation: 2,601 tests.Playwright drove the branch's embedded UI through a local HTTPS reverse proxy with a test provider: new browser tab → consent → HTTPS callback → PKCE token exchange → authenticated tool reads, with desktop and mobile checks.
OpenAPI regeneration and
git diff --checkpassed.The complete server suite is not claimed: its initial broad run lacked the required binary-path setting and exceeded the default ten-minute deadline. Relevant server tests were rerun successfully with that setting.
The two independent PR branches also merge without conflicts; their combined 14 affected frontend tests and production build pass.