Server metadata advertises the RFC 8414 issuer with a trailing slash (URL normalization in createOAuthMetadata)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- express, node.js, typescript
研究方向
Start in packages/server-legacy/src/auth/router.ts: read createOAuthMetadata and authorizationHandler, then trace how issuerUrl reaches both the metadata issuer and the RFC 9207 iss parameter. Compare with checkIssuerUrl and the e2e scenario hosting:auth:as-iss-emission, which currently pins the slashed form. Done means both fields are byte-identical and slash-less for root issuers and the regression tests named in PR #3184 pass.
由索引模型根據 Issue 內容生成。
描述
Description
createOAuthMetadata (packages/server-legacy/src/auth/router.ts) writes the metadata issuer as issuerUrl.href. Because new URL('https://host').href normalizes to https://host/, an authorization server built from a slash-less origin string advertises its issuer with a trailing slash.
RFC 8414 §2 forbids a trailing slash on the issuer identifier, and §3.3 requires the metadata issuer to be byte-identical to the URL the well-known document was fetched from.
Reproduction
import express from 'express';
import { mcpAuthRouter } from '@modelcontextprotocol/sdk/server/auth/router.js';
// minimal provider stub…
const app = express();
app.use(mcpAuthRouter({
provider: mockProvider,
issuerUrl: new URL('https://auth.example.com'), // no trailing slash — the usual case
}));
app.listen(3000);
curl -s http://localhost:3000/.well-known/oauth-authorization-server | jq .issuer
# → "https://auth.example.com/" ← slash appeared
# expected → "https://auth.example.com"
The SDK's own client fails the same round trip: discoverAuthorizationServerMetadata validates the metadata issuer echo against the discovery URL and throws IssuerMismatchError when they differ. So on SDK 1.32.x an SDK server and an SDK client cannot complete OAuth discovery against each other for any root issuer — and other strict RFC 8414 clients (Python SDK's validate_metadata_issuer, OpenCodealt's client, …) reject it identically. We hit this in production: strict clients could not connect any OAuth-protected MCP behind our authorization server until we patched the served document.
Proposed fix
packages/server-legacy/src/auth/router.ts — derive the identifier slash-less before writing the field (an issuerIdentifierOf() that strips the single normalization slash); both new URL('https://host') and new URL('https://host/') then serve the same compliant metadata. The RFC 9207 iss parameter emitted by authorizationHandler has the same normalization and needs the same treatment to stay byte-identical with the metadata issuer (its e2e scenario hosting:auth:as-iss-emission currently pins the slashed form).
Upstream PR with the fix + regression tests: #3184
Additional context
- The client side needs no change — main's
IssuerMismatchErrorecho check is correct and already tolerates a slashed discovery URL against a slash-less metadata issuer; it's the server document that's wrong. - Related but distinct: #1968 covered the client-side
resourceindicator trailing slash; this is the server-sideissuerfield, still unfixed on main. - Happy to rebase/adjust if maintainers would rather enforce this in
checkIssuerUrl(rejecting slashed input) than normalize on output — normalizing was chosen for backward compatibility with existing deployments.
- 主要語言
- TypeScript
- 星號
- 13.8k
- 分支
- 2.5k
- 平均合併
- 6 天 23 小時
- 30 天內合併 PR
- 2
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
modelcontextprotocol/typescript-sdk 的其他 Issue
-
v2
難度 1/5 1 小時以內 新手友好度 72/100
modelcontextprotocol/typescript-sdk#3270 · 1 則留言 ·
維護者通常 1 天內回覆
-
`callTool` with `allowInputRequired: true` throws on an `input_required` result when the tool declares an `outputSchema`可能已有人在做 @mgoldsborough 於 6 天前認領。 未關閉v2
難度 2/5 1-3 小時 新手友好度 78/100
modelcontextprotocol/typescript-sdk#3249 ·
維護者通常 1 天內回覆
-
v2
難度 2/5 1-3 小時 新手友好度 68/100
modelcontextprotocol/typescript-sdk#3243 · 3 則留言 ·
維護者通常 1 天內回覆
-
TypeScript client accepts an unknown `resultType` in the first `server/discover` reply可能已有人在做 @Tidehyc 於 8 天前認領。 未關閉v2
難度 2/5 1-3 小時 新手友好度 72/100
modelcontextprotocol/typescript-sdk#3235 · 3 則留言 ·
維護者通常 1 天內回覆
-
UriTemplate.match() throws a TypeError on an empty expression it accepts可能已有人在做 @yunusemrejs 於 12 天前認領。 未關閉v1 v2
難度 2/5 1-3 小時 新手友好度 80/100
modelcontextprotocol/typescript-sdk#3221 · 3 則留言 ·
維護者通常 1 天內回覆
查看 modelcontextprotocol/typescript-sdk 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 68/100
Vessel9817/onion-site-template#512 ·
維護者通常 1 天內回覆
-
nightly-tests
難度 2/5 1-3 小時 新手友好度 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
維護者通常 1 天內回覆
-
approved
難度 2/5 1-3 小時 新手友好度 85/100
fritzprix/libr-agent#3266 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
better-auth/better-auth#13101 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆