Commit 96c7a43
committed
fix: strip trailing slashes from OAuth metadata URL fields
Pydantic's AnyHttpUrl automatically appends a trailing slash to bare
hostnames (e.g., http://localhost:8000 becomes http://localhost:8000/).
This causes OAuth discovery to fail in clients that validate per
RFC 8414 §3.3 and RFC 9728 §3, which require the returned issuer/resource
URL to be identical to the URL used for discovery.
Add field_serializer to OAuthMetadata.issuer,
ProtectedResourceMetadata.resource, and
ProtectedResourceMetadata.authorization_servers to strip the trailing
slash during JSON serialization.
Fixes #1919
Fixes #1265
Reported-by: joar
Github-Issue: #19191 parent 5301298 commit 96c7a43
File tree
4 files changed
+28
-10
lines changed- tests
- client
- server
- auth
- fastmcp/auth
4 files changed
+28
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
132 | 138 | | |
133 | 139 | | |
134 | 140 | | |
| |||
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1283 | 1283 | | |
1284 | 1284 | | |
1285 | 1285 | | |
| 1286 | + | |
1286 | 1287 | | |
1287 | 1288 | | |
1288 | 1289 | | |
1289 | 1290 | | |
1290 | 1291 | | |
1291 | 1292 | | |
1292 | 1293 | | |
1293 | | - | |
1294 | | - | |
1295 | 1294 | | |
| 1295 | + | |
1296 | 1296 | | |
1297 | 1297 | | |
1298 | 1298 | | |
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
1302 | 1302 | | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
1306 | 1303 | | |
1307 | 1304 | | |
1308 | 1305 | | |
| 1306 | + | |
1309 | 1307 | | |
1310 | 1308 | | |
1311 | 1309 | | |
| |||
1314 | 1312 | | |
1315 | 1313 | | |
1316 | 1314 | | |
| 1315 | + | |
1317 | 1316 | | |
1318 | 1317 | | |
1319 | 1318 | | |
| |||
1326 | 1325 | | |
1327 | 1326 | | |
1328 | 1327 | | |
| 1328 | + | |
1329 | 1329 | | |
1330 | 1330 | | |
1331 | 1331 | | |
| |||
1341 | 1341 | | |
1342 | 1342 | | |
1343 | 1343 | | |
1344 | | - | |
| 1344 | + | |
1345 | 1345 | | |
1346 | 1346 | | |
1347 | 1347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
| 99 | + | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
| 314 | + | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| |||
0 commit comments