Repository navigation
fix: construct RFC 8414 metadata URL correctly for path-based issuers - #1206
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes OAuth Authorization Server Metadata discovery for path-based issuer URLs in the MCP auth flow by constructing the RFC 8414 metadata URL using the issuer’s origin plus the well-known prefix plus the issuer path.
Changes:
- Update
authorization_server_metadata()to use an RFC 8414-compliant metadata URL builder. - Add
rfc8414_metadata_url()helper for constructing the metadata endpoint from an issuer URL. - Add unit tests covering path-based issuers and trailing-slash handling.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| let origin = parsed.origin().ascii_serialization(); | ||
| let path = parsed.path(); | ||
| format!("{origin}/.well-known/oauth-authorization-server{path}") | ||
| }, |
There was a problem hiding this comment.
url::Url::parse("https://idp.example.com") yields path of "/", so this currently produces .../.well-known/oauth-authorization-server/ (extra trailing slash). That differs from RFC 8414 Section 3 (no trailing slash for root issuers), contradicts the doc comment above, and changes the previous behavior. Consider special-casing path == "/" to append an empty path (or otherwise avoid adding the trailing "/").
| fn test_rfc8414_metadata_url_root_issuer() { | ||
| assert_eq!( | ||
| rfc8414_metadata_url("https://idp.example.com"), | ||
| "https://idp.example.com/.well-known/oauth-authorization-server/" | ||
| ); |
There was a problem hiding this comment.
This test currently expects a trailing slash for a root issuer (.../oauth-authorization-server/), which doesn’t match RFC 8414 Section 3 and also contradicts the doc comment above that says root issuers should produce the same result as before. Update the expected value accordingly, and consider adding a companion case for an input issuer with a trailing slash (https://idp.example.com/).
Fixes agentgateway#1205 Signed-off-by: kimsehwan96 <[email protected]>
b2e933c to
f4404c9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…agentgateway#1206) Fixes agentgateway#1205 The well-known suffix was appended to the end of the issuer URL instead of being inserted between the origin and path per RFC 8414 Section 3, which broke metadata discovery for any IdP with a path-based issuer (e.g. Authentik). Signed-off-by: kimsehwan96 <[email protected]>
Fixes #1205
The well-known suffix was appended to the end of the issuer URL instead of being inserted between the origin and path per RFC 8414 Section 3, which broke metadata discovery for any IdP with a path-based issuer (e.g. Authentik).