Repository navigation
Commit 9d031c0
authored
fix(oauth): abort with oauth_client_id_required instead of empty-client_id authorize URL (#976)
* fix(oauth): abort with oauth_client_id_required instead of emitting empty-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.
* fix(oauth): guard third URL-emission path + preserve real DCR outcome 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.
* fix(oauth): diagnose extra_params client_id escape hatch + widen best-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).
* fix(oauth): drop incorrect extra_params token-exchange warning
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.1 parent 2b90a10 commit 9d031c0
2 files changed
Lines changed: 232 additions & 72 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1010 | 1010 | | |
1011 | 1011 | | |
1012 | 1012 | | |
| 1013 | + | |
1013 | 1014 | | |
1014 | 1015 | | |
1015 | 1016 | | |
| |||
1040 | 1041 | | |
1041 | 1042 | | |
1042 | 1043 | | |
1043 | | - | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
1044 | 1047 | | |
1045 | 1048 | | |
1046 | 1049 | | |
| |||
1080 | 1083 | | |
1081 | 1084 | | |
1082 | 1085 | | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
1086 | 1091 | | |
1087 | 1092 | | |
1088 | 1093 | | |
| |||
1159 | 1164 | | |
1160 | 1165 | | |
1161 | 1166 | | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
1192 | 1173 | | |
1193 | 1174 | | |
1194 | 1175 | | |
| |||
1393 | 1374 | | |
1394 | 1375 | | |
1395 | 1376 | | |
| 1377 | + | |
1396 | 1378 | | |
1397 | 1379 | | |
1398 | 1380 | | |
| |||
1412 | 1394 | | |
1413 | 1395 | | |
1414 | 1396 | | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
1415 | 1400 | | |
1416 | 1401 | | |
1417 | 1402 | | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
1427 | | - | |
1428 | | - | |
1429 | | - | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
1433 | | - | |
1434 | | - | |
1435 | | - | |
1436 | | - | |
1437 | | - | |
1438 | | - | |
1439 | | - | |
1440 | 1403 | | |
1441 | 1404 | | |
1442 | 1405 | | |
| |||
1519 | 1482 | | |
1520 | 1483 | | |
1521 | 1484 | | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
1522 | 1491 | | |
1523 | 1492 | | |
1524 | 1493 | | |
| |||
1914 | 1883 | | |
1915 | 1884 | | |
1916 | 1885 | | |
| 1886 | + | |
1917 | 1887 | | |
1918 | 1888 | | |
1919 | 1889 | | |
| |||
1930 | 1900 | | |
1931 | 1901 | | |
1932 | 1902 | | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
1933 | 1906 | | |
1934 | 1907 | | |
1935 | 1908 | | |
1936 | 1909 | | |
1937 | | - | |
1938 | | - | |
1939 | | - | |
1940 | | - | |
1941 | | - | |
1942 | | - | |
1943 | | - | |
1944 | | - | |
1945 | | - | |
1946 | | - | |
1947 | | - | |
1948 | | - | |
1949 | | - | |
1950 | | - | |
1951 | | - | |
1952 | | - | |
1953 | 1910 | | |
1954 | 1911 | | |
1955 | 1912 | | |
| |||
2017 | 1974 | | |
2018 | 1975 | | |
2019 | 1976 | | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
2020 | 1983 | | |
2021 | 1984 | | |
2022 | 1985 | | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
2023 | 2045 | | |
2024 | 2046 | | |
2025 | 2047 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
0 commit comments