auth: resource metadata lookup accepts URLs from non-Bearer challenges
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- authentication, backend-api-design
Hướng nghiên cứu
Đọc resourceMetadataURLFromChallenges và so sánh cách lọc của nó với scopesFromChallenges và errorFromChallenges. Chạy bài kiểm thử hồi quy ở cấp package được nêu trong issue, sau đó thêm bài kiểm thử đó bên cạnh các bài kiểm thử hiện có của helper. Hoàn tất khi các challenge không phải Bearer bị bỏ qua và URL metadata tài nguyên của challenge Bearer được trả về.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 5.2k
- Fork
- 583
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 52
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/go-sdk
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
modelcontextprotocol/go-sdk#1372 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Session-lifecycle bookkeeping logs at info, spamming multiple log lines per request on stateless streamable HTTPCó thể đã có người làm @anneheartrecord đã nhận 47 ngày trước. Đang mởP3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/go-sdk#1204 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsCó thể đã có người làm @ajuijas đã nhận 213 ngày trước. Đang mởneeds investigation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/go-sdk#745 · 13 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/go-sdk#1394 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp: rejected request IDs receive no JSON-RPC error envelopeCó thể đã có người làm @skosovsky đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 68/100
modelcontextprotocol/go-sdk#1391 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/go-sdk
Issue tương tự
-
bug performance scalability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Davidjustice28/basildb#35 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rhysd/actionlint#761 ·
-
bug needs-triage P2 tier:1-mechanical
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
krakenhavoc/cmd_and_ctrl#3652 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
puppe1990/amarra-cais#345 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
limitlessprojects/Go-Hybrid#50 ·
Maintainer thường phản hồi trong vòng 1 ngày