Commit fc762df
fix: respect token_endpoint_auth_method=none when a client secret is stored
A client that registers with token_endpoint_auth_method="none" is a public
client, so ClientAuthenticator sets request_client_secret to None for it. The
stored-secret check that follows did not look at the auth method, so a secret
left on the client record by an earlier confidential registration made the
token request fail with "Client secret is required".
RFC 6749 section 2.1 says the authorization server should not make assumptions
about the client type. Honouring a leftover secret over the client's own
declaration does exactly that, so skip the check when the method is "none".
The `and client.client_secret` half of the condition is redundant against the
misconfiguration guard above it, but it keeps the type narrowing that the
compare_digest call below relies on.
Fixes #1842
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H53v9BN6gzMtKyAGAgdbDb1 parent 9972c21 commit fc762df
2 files changed
Lines changed: 61 additions & 2 deletions
File tree
- src/mcp/server/auth/middleware
- tests/server/mcpserver/auth
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1382 | 1382 | | |
1383 | 1383 | | |
1384 | 1384 | | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1385 | 1441 | | |
1386 | 1442 | | |
1387 | 1443 | | |
| |||
0 commit comments