Uh oh!
There was an error while loading. Please reload this page.
fix(sdk): try the OIDC path-appended well-known during OAuth discovery - #1718
Open
mpressiv-vault wants to merge 1 commit into
Open
Conversation
Authorization server metadata was only probed at the two path-insertion
locations, so an issuer mounted under a path that serves its metadata at
`{issuer}/.well-known/openid-configuration` was reported as having no
metadata at all. OIDC Discovery 1.0 section 4 defines that location and the
MCP authorization spec requires clients to try it, so add it as a third
candidate after the existing two.
Real-world case: TikTok's Ads MCP server at
https://business-api.tiktok.com/open_mcp/tt-ads-mcp-flat advertises an
issuer under `/open_mcp/tt-ads-mcp-flat/oauth` and serves metadata only at
the path-appended location. Discovery failed there while the server was
configured correctly, forcing callers to register clients by hand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
discoverAuthorizationServerMetadataonly probes the two path-insertion well-known locations:{origin}/.well-known/oauth-authorization-server{path}{origin}/.well-known/openid-configuration{path}An authorization server whose issuer is mounted under a path may serve its metadata at the path-appended location instead,
{issuer}/.well-known/openid-configuration. OpenID Connect Discovery 1.0 §4 defines that location, and the MCP authorization specification requires clients to try it as well. Today discovery returns "no metadata" for such a server even though it is configured correctly, andoauth.probefails withNo OAuth authorization-server metadata found at <endpoint>.Concrete case: TikTok's Ads MCP server at
https://business-api.tiktok.com/open_mcp/tt-ads-mcp-flat. Its401correctly points at protected resource metadata, which names the issuerhttps://business-api.tiktok.com/open_mcp/tt-ads-mcp-flat/oauth. That issuer answers on:and 404s on the path-insertion forms, so discovery fails and the only way through is registering the client by hand with metadata fetched outside Executor.
Change
Replace
wellKnownUrlForwithwellKnownCandidatesFor, which returns the existing two URLs plus, when the issuer has a path, the OIDC path-appended URL as a third candidate. Ordering and every other behaviour (per-candidate error tolerance, metadata validation, the surfacedmetadataUrl) are unchanged, and issuers without a path produce exactly the same two requests as before.Verification
oauth-discovery.test.tsserves metadata only at the path-appended location and asserts it is found. It fails onmainand passes with this change.vitest run src/oauth-discovery.test.tsinpackages/core/sdk: 26 passed.oxlinton both files: 0 warnings, 0 errors.oxfmt --check: clean.tsgo --noEmitfor the package: no new diagnostics.Notes for the maintainer
withOAuthFixturepattern used by every other case inoauth-discovery.test.ts.AGENTS.mdasks for@executor-js/emulatefor OAuth/OIDC providers, so happy to move it there if you would rather have the whole file migrate at once.Effect.result. A candidate that answers200with malformed JSON, or whose metadata fails validation, aborts discovery before the remaining candidates are tried. Left alone here to keep this PR to one behaviour change; glad to open a follow-up.