auth: resource metadata lookup accepts URLs from non-Bearer challenges
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- go
调研方向
阅读 resourceMetadataURLFromChallenges,并将其筛选逻辑与 scopesFromChallenges 和 errorFromChallenges 进行比较。运行 issue 中给出的包级回归测试,然后将其添加到 helper 现有的测试中。当非 Bearer challenge 被忽略且返回 Bearer challenge 的资源元数据 URL 时,即为完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
auth.resourceMetadataURLFromChallenges returns the first resource_metadata auth-param without checking the challenge scheme. The adjacent scopesFromChallenges and errorFromChallenges helpers correctly restrict their lookups to Bearer challenges.
As a result, a mixed response such as:
WWW-Authenticate: Basic resource_metadata="https://basic.example/metadata", Bearer resource_metadata="https://mcp.example/metadata"
causes AuthorizationCodeHandler to discover OAuth metadata from https://basic.example/metadata, even though resource_metadata is an MCP Bearer-challenge parameter and the Bearer challenge points elsewhere.
To Reproduce
On main at 944ac19, this package-level test fails:
func TestResourceMetadataURLFromChallengesIgnoresNonBearer(t *testing.T) {
challenges := []oauthex.Challenge{
{Scheme: "basic", Params: map[string]string{"resource_metadata": "https://basic.example/metadata"}},
{Scheme: "bearer", Params: map[string]string{"resource_metadata": "https://mcp.example/metadata"}},
}
if got, want := resourceMetadataURLFromChallenges(challenges), "https://mcp.example/metadata"; got != want {
t.Fatalf("resourceMetadataURLFromChallenges() = %q, want %q", got, want)
}
}
The current result is https://basic.example/metadata.
Expected behavior
Only a Bearer challenge should supply resource_metadata, matching the filtering already used for scope and error. The current MCP authorization examples attach resource_metadata to the Bearer challenge, and RFC 6750 defines Bearer challenge parameters in WWW-Authenticate.
Additional context
The fix should be a small, unexported behavior correction: require c.Scheme == "bearer" in resourceMetadataURLFromChallenges and add the mixed-challenge regression test above. I would be happy to send that PR if this approach looks right.
Environment: go-sdk main at 944ac19, Go 1.25.0, macOS/arm64.
AI assistance disclosure: I used Codex to inspect the auth flow and draft the reproducer; I reviewed the source, specification references, and issue text.
- 主要语言
- Go
- 星标
- 5.3k
- 派生
- 607
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 80
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/go-sdk 的其他 Issue
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensions可能重新可做 关联的 PR 已关闭且未合并。 未关闭needs investigation
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/go-sdk#745 · 13 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Proposal: export urlElicitationMiddleware可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 50/100
modelcontextprotocol/go-sdk#1492 · 1 条评论 ·
维护者通常 1 天内回复
-
mcp: ClientSession.CallTool omits Mcp-Param-* headers unless the tool is in the ListTools cache, so a call without a prior tools/list is rejected可能已有人在做 @huynle-dev 于 3 天前认领。 未关闭
难度 4/5 1-2 天 新手友好度 35/100
modelcontextprotocol/go-sdk#1481 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
mcp: list_changed can only be broadcast; a server cannot notify one session (2026-07-28 subscriptions/listen)可能已有人在做 @huynle-dev 于 3 天前认领。 未关闭
难度 4/5 1-2 天 新手友好度 32/100
modelcontextprotocol/go-sdk#1480 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
mcp: Client.Connect falls back to initialize after a 401 on server/discover, running the authorization flow twice可能已有人在做 @kerthans 于 15 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
modelcontextprotocol/go-sdk#1423 · 1 条评论 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/go-sdk 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
SAP/crossplane-provider-btp#1175 ·
维护者通常 1 天内回复
-
adk: stream concatenation errors bypass retry and failover可能已有人在做 @OUAO-FRANK 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
google/osv-scalibr#2586 ·
维护者通常 2 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
stacklok/toolhive-catalog#1890 ·
维护者通常 1 天内回复
-
heap: pushing an item that is already queued corrupts the index可能已有人在做 @lbarrosby 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
kubernetes-sigs/kwok#1800 ·
维护者通常 1 天内回复