Repository navigation
fix(oauth): make the redirect_uri pin actually reachable, diagnosable and validated - #1070
Merged
Merged
Conversation
added 2 commits
August 27, 2026 12:08
… and validated PR #1069 made the per-server `oauth.redirect_uri` field load-bearing for the first time. QA of the merged change found five defects on that newly-live path. - An `::1` pin was accepted, blessed by a test and advertised in the docs, but the callback listener was hard-coded to `net.Listen("tcp", "127.0.0.1:PORT")`. The provider was handed a `[::1]` URL nothing listened on, so the browser redirect was refused and the login hung to the callback timeout. The pin now carries its host: `localhost` and `127.0.0.1` bind IPv4, `::1` binds IPv6. - Every log line in `createOAuthConfigInternal` and in the callback-server manager went to `zap.L()`, which this repo never replaces, so all of it was discarded — including #1069's new "fail loudly" errors, and the docs claim that they appear in the logs. The connection's own logger is threaded in. - A malformed pin was a permanent connect failure reported as "failed to create OAuth config - server may not support OAuth", which never names the culprit. The parse error and the "pinned port unavailable" reason now reach the user-visible error, and the write surfaces (REST config API, MCP `upstream_servers`) reject a bad value up front. The boot path deliberately does not: a value already on disk must not stop the daemon from starting. The Gemini importer no longer copies a callback URL mcpproxy cannot honor. - `StartCallbackServer` returned a cached server without honoring the requested port, so a pinned reconnect after a timed-out flow failed against a free port. It now re-binds — but only when the cached server has no waiter parked on it, preserving the invariant #1068 established. - The pinned path skipped the stored-credential read, so Spec-022 legacy cleanup never ran and a DCR registration issued against a different port was reused forever. The read always runs now; only the port choice short-circuits. Docs: correct the wildcard-callback advice in mcp-go-oauth.md (GitHub OAuth Apps reject `http://127.0.0.1:*`), drop the non-existent `redirect_port` field from the callback-mismatch error page, fix the `:8080` example that collided with mcpproxy's own listener, and resolve the port-allocation contradiction. Follow-up to #1069. Refs #975, #1066.
GitHub added per-callback-URL wildcard matching in August 2026, so "rejects wildcards" is no longer accurate. The argument for pinning the port is unchanged and is what GitHub actually documents: wildcard matching covers subdomains and subdirectory paths, while the host and port must still match the registered callback exactly.
This was referenced Aug 27, 2026
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 33057272937 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 27, 2026
#1071) The `redirect_uri` pin was documented only in `docs/configuration.md`, which is not in the Docusaurus include list, so the link added in #1070 resolved to nothing and broke the docs build on main. Move the guidance to `configuration/upstream-servers.md`, which is the per-server page the site actually publishes, and point both links at it. Verified with a local `npm run build` — no broken links. Co-authored-by: Algis Dumbris <gordon.greatests@gmail.com>
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1069, which made the per-server
oauth.redirect_urifield load-bearing for the first time. A QA sweep of the merged change — unit, adversarial review, and live end-to-end againsttests/oauthserverwith DCR disabled — found five defects on that newly-live path. Each was independently verified before being fixed.What was broken
::1pins were accepted, blessed by a test and advertised in the docs, but the listener was hard-coded tonet.Listen("tcp", "127.0.0.1:PORT")[::1]URL nothing listened on. The browser redirect was refused and the login hung to the callback timeout, with no diagnostic.createOAuthConfigInternaland the callback-server manager logged tozap.L(), which this repo never replacesdocs/configuration.mdclaimed the opposite.failed to create OAuth config - server may not support OAuthredirect_uri, and nothing rejected the value at write time. Reachable without typing anything: the Gemini importer copiedhttp://localhost:7777/oauth2callbackverbatim.StartCallbackServerreturned a cached server without honoring the requested portWhat changed
ParsePinnedRedirectURIreturns(host, port),StartCallbackServerOnHostbinds it:localhostand127.0.0.1bind IPv4,::1binds IPv6. The listener address,http.Server.AddrandCallbackServer.RedirectURIare all built from what was actually bound, so the unpinned path stays consistent too.createOAuthConfigInternaland the callback-server manager. The old exported signatures are kept as wrappers.OAuthConfig.Validate()gains aredirect_uricheck wired intoValidateDetailed(), so every write surface (REST config API, MCPupstream_servers) rejects a bad value. The boot path deliberately does not:Validate()runsvalidateDetailedCore(), so a value already on disk cannot brick a load that has nothing to do with the offending server — it fails loudly at connect time instead. The Gemini importer drops a callback URL mcpproxy cannot honor and warns.Parsing lives in
internal/config.ParsePinnedRedirectURIandinternal/oauthdelegates to it, so validation and the OAuth flow cannot diverge.Docs
mcp-go-oauth.md§7.1 told operators to registerhttp://127.0.0.1:*. GitHub OAuth Apps reject wildcard callback URLs — this is the advice that sent the reporter of GitHub MCP OAuth DCR opens authorization URL with empty client_id #975 down a dead end. Corrected to distinguish providers that permit a wildcard from those that require an exact URL.errors/MCPX_OAUTH_CALLBACK_MISMATCH.mddocumented aredirect_portconfig field that does not exist.configuration.md: the example pinned:8080, mcpproxy's own default listener, so copying it verbatim broke every login; and the section contradicted itself on port allocation.features/oauth-authentication.mdstill describedredirect_urias cosmetic.Verification
Live E2E against the in-tree fake provider (DCR disabled, GitHub-shaped), isolated core, headless:
client_id, no pin — port58007held across a full core restart (regression guard for fix(oauth): keep the loopback callback port stable for static clients #1069).127.0.0.1:18942— sent verbatim, bound exactly, login completed.[::1]:18943—lsofshowsTCP [::1]:18943 (LISTEN); anAF_INET6connect succeeds whileAF_INETto127.0.0.1:18943is refused, proving a real IPv6 bind and not dual-stack. The full login completed through the[::1]callback URL.localhost:18944— binds IPv4, spelling preserved, login completed.redirect_uri, and so does the user-visible error.go build(both editions),gofmt,go test -raceacrossinternal/oauth,internal/config,internal/configimport,internal/upstream/..., andgolangci-lintv2 with the CI config: all green, 0 issues.Refs #975, #1066.