Repository navigation
Commit dc8efd9
committed
Replace authorization request parameters the endpoint URL already carries
## Motivation and Context
`Flow#build_authorization_url` appended the flow's parameters after whatever query the authorization server
metadata's `authorization_endpoint` already carried. An endpoint URL carrying `client_id`, `redirect_uri`,
`state`, `code_challenge`, or `resource` of its own therefore produced a request with each of them twice,
the URL's value first. RFC 6749 Section 3.1 forbids sending a parameter more than once, and which value
a server honors is its own choice; on the legacy 2025-03-26 path the endpoint URL is served by the MCP server itself,
so its query could speak for the client's identity, redirect URI, PKCE challenge, and resource at the authorization server.
A parameter the flow sets now replaces one of the same name in the endpoint URL, and the rest of the URL's query is kept,
which is what the TypeScript SDK's `searchParams.set` does.
`request` and `request_uri` are dropped from the endpoint URL's query as well, although the flow sets neither.
RFC 9101 has an authorization server take the whole authorization request from the object they carry,
over every parameter in the query, and both are the client's to send, so an endpoint URL holding one of them
could speak for the client through that door too. A `scope` in the endpoint URL stays when the flow has none of its own,
as it does in the TypeScript SDK: an authorization server may place a default scope on its own endpoint URL.
## How Has This Been Tested?
A new test in `test/mcp/client/oauth/flow_test.rb` serves an `authorization_endpoint` whose query carries
those parameters and one more, and checks that the authorization URL holds each parameter once with
the flow's value while keeping the extra one. It fails against the previous library.
Two more tests in the same file check that `request` and `request_uri` in the endpoint URL's query are dropped,
and that a `scope` there stays when the flow has none; the first of them fails against the previous library.
## Breaking Changes
None.1 parent 339f0a6 commit dc8efd9
2 files changed
Lines changed: 102 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
1219 | 1233 | | |
1220 | 1234 | | |
1221 | 1235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1572 | 1572 | | |
1573 | 1573 | | |
1574 | 1574 | | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
1575 | 1621 | | |
1576 | 1622 | | |
1577 | 1623 | | |
| |||
4436 | 4482 | | |
4437 | 4483 | | |
4438 | 4484 | | |
| 4485 | + | |
| 4486 | + | |
| 4487 | + | |
| 4488 | + | |
| 4489 | + | |
| 4490 | + | |
| 4491 | + | |
| 4492 | + | |
| 4493 | + | |
| 4494 | + | |
| 4495 | + | |
| 4496 | + | |
| 4497 | + | |
| 4498 | + | |
| 4499 | + | |
| 4500 | + | |
| 4501 | + | |
| 4502 | + | |
| 4503 | + | |
| 4504 | + | |
| 4505 | + | |
| 4506 | + | |
| 4507 | + | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
4439 | 4517 | | |
4440 | 4518 | | |
4441 | 4519 | | |
| |||
0 commit comments