Commit 74d3787
committed
fix(auth): preserve resource URI without trailing slash (#1968)
When handling RFC 9728 protected resource metadata, `selectResourceURL`
routed the metadata's `resource` value through `new URL(...).href`. For
bare-origin URIs that round trip appends a trailing slash:
new URL("https://example.com").href === "https://example.com/"
The resulting `resource` parameter no longer matches what the server
published in PRM, which breaks providers that require an exact match.
Microsoft Entra ID rejects the request with AADSTS9010010 when the
`resource` parameter does not match the audience of the requested scope.
Return the original metadata string verbatim from `selectResourceURL`
and serialize it with `String(resource)` instead of `URL.href` in the
authorization and token request paths. The validation step still parses
the value as a URL via `checkResourceAllowed`. Also adjusted the cached
discovery-state test to expect the un-normalized resource value, and
added a regression test for the bare-domain case.
Fixes #19681 parent bf1e022 commit 74d3787
2 files changed
Lines changed: 72 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
636 | | - | |
| 636 | + | |
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
653 | | - | |
654 | | - | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
655 | 659 | | |
656 | 660 | | |
657 | 661 | | |
| |||
1126 | 1130 | | |
1127 | 1131 | | |
1128 | 1132 | | |
1129 | | - | |
| 1133 | + | |
1130 | 1134 | | |
1131 | 1135 | | |
1132 | 1136 | | |
| |||
1174 | 1178 | | |
1175 | 1179 | | |
1176 | 1180 | | |
1177 | | - | |
| 1181 | + | |
1178 | 1182 | | |
1179 | 1183 | | |
1180 | 1184 | | |
| |||
1222 | 1226 | | |
1223 | 1227 | | |
1224 | 1228 | | |
1225 | | - | |
| 1229 | + | |
1226 | 1230 | | |
1227 | 1231 | | |
1228 | 1232 | | |
| |||
1234 | 1238 | | |
1235 | 1239 | | |
1236 | 1240 | | |
1237 | | - | |
| 1241 | + | |
1238 | 1242 | | |
1239 | 1243 | | |
1240 | 1244 | | |
| |||
1287 | 1291 | | |
1288 | 1292 | | |
1289 | 1293 | | |
1290 | | - | |
| 1294 | + | |
1291 | 1295 | | |
1292 | 1296 | | |
1293 | 1297 | | |
| |||
1329 | 1333 | | |
1330 | 1334 | | |
1331 | 1335 | | |
1332 | | - | |
| 1336 | + | |
1333 | 1337 | | |
1334 | 1338 | | |
1335 | 1339 | | |
| |||
1388 | 1392 | | |
1389 | 1393 | | |
1390 | 1394 | | |
1391 | | - | |
| 1395 | + | |
1392 | 1396 | | |
1393 | 1397 | | |
1394 | 1398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1153 | 1153 | | |
1154 | 1154 | | |
1155 | 1155 | | |
1156 | | - | |
| 1156 | + | |
| 1157 | + | |
1157 | 1158 | | |
1158 | 1159 | | |
1159 | 1160 | | |
1160 | | - | |
| 1161 | + | |
1161 | 1162 | | |
1162 | 1163 | | |
1163 | 1164 | | |
| |||
2562 | 2563 | | |
2563 | 2564 | | |
2564 | 2565 | | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
2565 | 2620 | | |
2566 | 2621 | | |
2567 | 2622 | | |
| |||
0 commit comments