Repository navigation
Accept a trailing slash on an origin-only DCR issuer - #7292
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7292 +/- ##
=======================================
Coverage 81.92% 81.93%
=======================================
Files 922 922
Lines 93314 93352 +38
=======================================
+ Hits 76451 76490 +39
+ Misses 16858 16857 -1
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
left a comment
There was a problem hiding this comment.
The relaxation looks right to me: it only applies when both sides are origin-only, scheme and host (including port) must still match, and path issuers keep byte-exact equality. The returned md.Issuer with the trailing slash doesn't leak anywhere either, since endpointsFromMetadata and the registrationEndpointServerSupplied authority check use upstreamIssuer derived from the operator's discovery URL, not the document's issuer.
Two things on the PR as a whole:
-
"must exactly match" is still the documented contract. I'd fold the
DiscoveryURLfield comment inpkg/authserver/config.gointo this PR rather than a follow-up: the regenerated swagger/CRD text is what operators read, and the repo guidance is to document operator-observable behaviour in the same PR. Two more comments in code this PR already touches say the same thing:FetchAuthorizationServerMetadataFromURLdoc comment (pkg/oauthproto/discovery.go, "issuer field must exactly match the caller-supplied expectedIssuer").deriveExpectedIssuerFromDiscoveryURLinpkg/auth/dcr/resolver.go, which describes the "§3.3 byte-equality check".
-
Scope is wider than the summary says.
fetchDiscoveryDocumentis shared, so the relaxation also applies toFetchAuthorizationServerMetadata, i.e. the CLI remote-server DCR path inpkg/auth/discovery/discovery.go, not onlydcrConfig.discoveryUrl. The behaviour is fine there too; worth a line in the PR body so reviewers know both paths changed.
|
Thanks for the review. Both points are in 33c27cf.
|
FastMCP-based authorization servers publish "issuer": "https://host/" for a root deployment, while ToolHive derives "https://host" from the discovery URL and compared the two byte for byte, so registration failed. Treat an empty path and "/" as equal for origin-only issuers (RFC 3986 section 6.2.3). Scheme, host and port still match exactly, and an issuer with a path keeps byte-exact equality. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Address review feedback on the trailing-slash issuer relaxation. The DiscoveryURL field, FetchAuthorizationServerMetadataFromURL and the DCR resolver still described the RFC 8414 section 3.3 check as byte-exact, which is no longer the contract operators get. Update those comments and regenerate the swagger and SDK docs so the published field description matches the behaviour. Also require a host in issuersEqual so an empty issuer never counts as origin-only, and replace the unparsable test case with one that only the parse-error branch rejects. Co-Authored-By: Claude Opus 5.5 <[email protected]>
33c27cf to
d3ddc49
Compare
Summary
dcrConfig.discoveryUrlcould not register against servers built on FastMCP's OAuth proxy. Those servers publish"issuer": "https://host.example.com/"for a root deployment, while ToolHive deriveshttps://host.example.comfrom the discovery URL and compared the two byte for byte. Registration failed withissuer mismatch (RFC 8414 §3.3).fetchDiscoveryDocumentnow compares issuers with a newissuersEqualhelper. For origin-only issuers it treats an empty path and/as equal (RFC 3986 §6.2.3).fetchDiscoveryDocumentis shared, so the relaxation applies to both callers: thedcrConfig.discoveryUrlpath (FetchAuthorizationServerMetadataFromURL) and the CLI remote-server DCR path (FetchAuthorizationServerMetadata, used frompkg/auth/discovery).DiscoveryURLfield comment, theFetchAuthorizationServerMetadataFromURLdoc comment and the DCR resolver comment no longer describe the check as byte-exact, and the swagger and SDK docs are regenerated to match.Fixes #7289
Type of change
Test plan
task test)task test-e2e)task lint-fix)task testcannot be scoped to one package, so I ran the full suite. Its only failure was the unrelatedpkg/networkingTestValidateCallbackPort("OAuth callback port 8090 is already in use"), caused by a port already bound on my machine. The test output hides passing packages, so CI is the first confirmation that the new tests ran and passed.Changes
pkg/oauthproto/discovery.goissuersEqualinstead of!=, update the doc commentpkg/oauthproto/discovery_test.goTestIssuersEqual, plus an end-to-end fetch against a server that publishes a trailing-slash issuerpkg/authserver/config.goDiscoveryURLcomment describes the relaxed issuer checkpkg/auth/dcr/resolver.godocs/server/*,sdk/go/*DiscoveryURLcommentDoes this introduce a user-facing change?
Yes.
This applies to both DCR discovery paths:
dcrConfig.discoveryUrland the CLI remote-server discovery.Before: an upstream whose metadata says
"issuer": "https://host.example.com/"was rejected when the expected issuer washttps://host.example.com, and the upstream was unusable.After: the two forms are accepted as the same issuer. Every other mismatch is still rejected, including different host, scheme or port, and
/tenantversus/tenant/.Special notes for reviewers
issuersEqualalso rejects userinfo, a bare?, opaque URLs and an empty host on either side. That is stricter than the sketch in the issue.🤖 Generated with Claude Code