Repository navigation
fix(oauth): abort with oauth_client_id_required instead of empty-client_id authorize URL - #976
Merged
Merged
Conversation
…mpty-client_id authorize URL (#975) When a provider lacks a Dynamic Client Registration endpoint (GitHub's https://github.com/login/oauth advertises none), mcpproxy swallowed the DCR failure and proceeded as a 'public client without client_id', producing https://github.com/login/oauth/authorize?client_id=&... which GitHub 404s. OAuth public clients (RFC 8252 + PKCE) still require a client_id — PKCE replaces the client secret, not the id. - New Client.emptyClientIDFlowError guard: parses the final authorization URL (after oauth.extra_params injection) and returns a structured oauth_client_id_required / OAUTH_NO_CLIENT_ID contracts.OAuthFlowError with an actionable suggestion when client_id is empty or absent. - Wired into getAuthorizationURLQuick (REST POST /servers/{name}/login and 'mcpproxy auth login' daemon path) which previously had no guard — the CLI used to print 'OAuth flow initiated successfully' and exit 0 on a broken URL; it now exits 1 with the structured error. - Replaces the connection path's 403-only inline check (Figma case), which misreported every DCR failure as 'returned 403'; the guard is now unconditional on the final URL in both paths. Verified live against api.githubcopilot.com on an isolated instance: REST login returns the structured error (no auth_url), CLI exits 1 with suggestion, and a configured oauth.client_id still produces a working authorize URL.
Deploying mcpproxy-docs with
|
| Latest commit: |
67a27b4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9a2109b7.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-975-oauth-empty-client-i.mcpproxy-docs.pages.dev |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… in error details Codex cross-review round 1 findings, both verified genuine: - handleOAuthAuthorizationWithResult (ForceOAuthFlowWithResult / manual CLI flows) still built, stored, and opened an empty-client_id authorize URL when DCR failed with anything other than a 403. Same guard now applied after extra-param injection, before the URL is stored or the browser opened. - The unified error previously discarded the actual DCR result (the old connection-path shape hardcoded 403/Forbidden for every failure, and the replacement dropped it entirely). emptyClientIDFlowError now takes the DCR error: details.dcr_status carries the real error text, with status_code=403 preserved when the failure was an actual 403 — a Figma-style rejection stays distinguishable from a GitHub-style missing registration endpoint. - All three 403-only early returns removed; every path now produces one consistent oauth_client_id_required shape via the final-URL guard. 3 new unit tests (403 details, unsupported details, no-DCR-attempt); verified live: REST login now returns dcr_status.error='server does not support dynamic client registration', zero authorize URLs in logs.
…-effort 403 detection Codex cross-review round 2, both verified: - A client_id injected only via oauth.extra_params passes the URL guard but is never sent by the handler at token exchange (mcp-go has no SetClientID), so it only works against lenient providers. Keep the escape hatch (pre-existing behavior) but WARN with a pointer to oauth.client_id so the post-callback failure is diagnosable. Guard now takes the handler via a clientIDProvider interface. - DCRStatus.StatusCode: also map 'Forbidden' to 403; documented as best-effort since mcp-go registration errors are untyped (a 403 with a valid OAuth JSON body surfaces without any status text) — the verbatim error string remains the authoritative detail. 2 new unit tests (10 total).
Codex round 3 (verified): OAuthTransportWrapper injects every oauth.extra_params entry — client_id included — into token request bodies, so an extra_params client_id DOES reach token exchange and the round-2 warning would have misdiagnosed working configurations. Warning and the clientIDProvider plumbing removed; the guard comment now documents why extra_params client_id pass-through is fully functional.
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 31682945858 --repo smart-mcp-proxy/mcpproxy-go
|
Contributor
There was a problem hiding this comment.
QA verified live (issue #975 repro + fix acceptance); Codex cross-review CLEAN after 4 rounds; qa-gate success at this SHA
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.
Fixes #975.
Root cause
GitHub's authorization server (
https://github.com/login/oauth) advertises noregistration_endpointin its RFC 8414 metadata, so Dynamic Client Registration is impossible. mcpproxy attempted DCR, gotserver does not support dynamic client registrationfrom mcp-go, logged a warning, and fell through to "public client OAuth with PKCE, no client_id" — a premise that is incorrect (OAuth public clients still require aclient_id; PKCE replaces the client secret, not the id). The result washttps://github.com/login/oauth/authorize?client_id=&…, which GitHub 404s.Two paths were affected:
getAuthorizationURLQuick(RESTPOST /api/v1/servers/{name}/login+mcpproxy auth logindaemon mode) had no empty-client_id guard at all — the CLI printed "OAuth authentication flow initiated successfully" and exited 0 on a guaranteed-broken URL.handleOAuthAuthorization(connection-triggered) had a guard, but only keyed on DCR errors containing "403" (the Figma case) and misreported every failure as "DCR returned 403".Fix
New
Client.emptyClientIDFlowErrorguard, wired into both paths: parses the final authorization URL (afteroauth.extra_paramsinjection, so a client_id supplied that way still passes) and returns a structuredoauth_client_id_required/OAUTH_NO_CLIENT_IDerror with an actionable suggestion instead of ever surfacing a broken URL.Verification (isolated instance against real api.githubcopilot.com)
success:truewithauth_url=…client_id=&…; CLI → exit 0 "flow initiated successfully".success:false, error_type=oauth_client_id_requiredwith suggestion to setoauth.client_id; CLI → exit 1 with the full structured error block; zero authorize URLs in logs."oauth": {"client_id": "…"}configured, the login flow still returns a working authorize URL carrying that client_id.go test -race ./internal/upstream/... ./internal/oauth/...green; both editions build;golangci-lint(CI v2 config) 0 issues; 5 new unit tests for the guard.