Commit 3dbb6b2
Olivier Gintrand
fix: include resource_metadata in all 401 WWW-Authenticate responses
Move the per-server OAuth enforcement check before the empty-bearer
and strict-mode checks in _auth_no_token(), and propagate the
enriched WWW-Authenticate header (with RFC 9728 resource_metadata
attribute) to all 401 responses.
Previously, when a client sent an empty Bearer header to an
OAuth-enabled server, the empty-bearer check fired first and
returned a generic 'Bearer' WWW-Authenticate without the
resource_metadata URL. MCP clients (Open WebUI, VS Code) could
not discover the OAuth authorization server to initiate the flow.
Now the per-server check always runs first, so if the target server
has oauth_enabled=true, the 401 response includes the
resource_metadata attribute regardless of which check triggers the
rejection.
Fixes #3990
Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.com>1 parent a2aa82a commit 3dbb6b2
1 file changed
+11
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3481 | 3481 | | |
3482 | 3482 | | |
3483 | 3483 | | |
3484 | | - | |
3485 | | - | |
3486 | | - | |
3487 | | - | |
3488 | | - | |
3489 | | - | |
3490 | | - | |
3491 | | - | |
3492 | | - | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
3493 | 3489 | | |
3494 | 3490 | | |
3495 | 3491 | | |
| |||
3503 | 3499 | | |
3504 | 3500 | | |
3505 | 3501 | | |
3506 | | - | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
3507 | 3507 | | |
3508 | | - | |
| 3508 | + | |
3509 | 3509 | | |
3510 | 3510 | | |
3511 | 3511 | | |
| |||
0 commit comments