Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

auth: resource metadata lookup accepts URLs from non-Bearer challenges

Đã đóng Phù hợp với người mới
#1,379 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@jay23606 đang làm issue này rồi.

Từ ngày 12/10/2026.

  • #1396 của @jay23606 — đang mở

Đá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

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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/go-sdk

Tất cả issue của modelcontextprotocol/go-sdk

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.