Skip to content

fix(core): drop trailing slashes when deriving the PRM well-known path - #16

Closed
RobertoIskandarani wants to merge 1 commit into
mainfrom
rob/prm-wellknown-trailing-slash
Closed

fix(core): drop trailing slashes when deriving the PRM well-known path#16
RobertoIskandarani wants to merge 1 commit into
mainfrom
rob/prm-wellknown-trailing-slash

Conversation

@RobertoIskandarani

Copy link
Copy Markdown
Collaborator

What

ProtectedResourceMetadata.wellKnownPath now drops trailing slashes from the resource path when deriving the RFC 9728 well-known PRM path:

  • https://api.example.com/mcp//.well-known/oauth-protected-resource/mcp (previously /mcp/)
  • https://api.example.com//.well-known/oauth-protected-resource (unchanged)

wellKnownUrl previously carried its own partial normalization (a single-slash strip); it now delegates entirely to wellKnownPath. All PRM path consumers (AuthplaneResource.prmPath()/prmUrl(), the MCP setup, both Spring configs) route through this single method.

Why

This aligns java-sdk with the family convention already shipped in ts-sdk, python-sdk, and rust-sdk: identifiers differing only by a trailing slash resolve to the same metadata document. Without this, a resource configured as .../mcp/ serves its PRM at a route a client deriving from .../mcp never probes, and discovery 404s.

The conformance catalog pins this in rfc9728-well-known-path-must-derive-from-resource-uri (AuthPlane/conformance#3).

Scope boundary: only the well-known path derivation normalizes. The resource field inside the PRM document and issuer/resource identity comparisons (RFC 8414/9728 §3.3, RFC 9068 iss) remain exact-string. MetadataUrlBuilder.buildMetadataUrl (RFC 8414) already stripped the issuer's trailing slash — no change there.

Validation

  • mvn test -B: BUILD SUCCESS — core 730, mcp 62, spring 115 (907 tests, 0 failures; 1 pre-existing unrelated skip).
  • Rfc9728ConformanceTest (pinned to catalog case rfc9728-well-known-path-must-derive-from-resource-uri) extended with both trailing-slash assertions.

RFC 9728 section 3 inserts the well-known segment between the authority
and the resource path. Resource identifiers that differ only by a
trailing slash must resolve to the same metadata document, so
ProtectedResourceMetadata.wellKnownPath now drops trailing slashes from
the resource path before appending it:

  https://api.example.com/mcp/ -> /.well-known/oauth-protected-resource/mcp
  https://api.example.com/     -> /.well-known/oauth-protected-resource

This matches the derivation already shipped by the TypeScript, Python,
and Rust SDKs. Only the well-known path derivation normalizes; the
resource field in the PRM document and issuer/resource identity
comparisons remain exact-string.

wellKnownUrl now delegates the normalization to wellKnownPath instead
of pre-stripping a single trailing slash itself.
@RobertoIskandarani
RobertoIskandarani requested a review from a team as a code owner July 30, 2026 17:16
@RobertoIskandarani

Copy link
Copy Markdown
Collaborator Author

Moving to the internal review flow.

@RobertoIskandarani
RobertoIskandarani deleted the rob/prm-wellknown-trailing-slash branch July 30, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant