ClientAuthenticator ignores token_endpoint_auth_method="none" when client_secret is stored

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

Chưa có ai nhận issue nà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
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
authentication

Hướng nghiên cứu

Bắt đầu tại src/mcp/server/auth/middleware/client_auth.py, ở logic ClientAuthenticator được liên kết. Tái hiện trường hợp token_endpoint_auth_method là none trong khi một client secret được lưu trữ, sau đó xác minh rằng không yêu cầu thông tin xác thực của request đối với phương thức này và các phương thức khác vẫn giữ nguyên các kiểm tra của chúng. Thêm hoặc cập nhật kiểm thử xác thực liên quan để bao quát hành vi này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

auth bug needs confirmation needs decision P2
Initial Checks
Description

ClientAuthenticator behavior is only partially honoring token_endpoint_auth_method="none":

https://github.com/modelcontextprotocol/python-sdk/blob/6b69f6354ad01e08abc8e1b81390c3a45132f594/src/mcp/server/auth/middleware/client_auth.py#L102-L104

Essentially:

  • token_endpoint_auth_method="none" => skip extracting credentials from the request (correct)
  • client.client_secret exists => raise error if no credentials were extracted from the request (incorrect)

If token_endpoint_auth_method="none" is set, it should never be checking for a client_secret value on the request, regardless of whether a secret has ever been generated for the client.

Suggested fix is to condition the client.client_secret check on token_endpoint_auth_method not being none:

        if token_endpoint_auth_method != "none" and client.client_secret:  # pragma: no branch
            if not request_client_secret:
                raise AuthenticationError("Client secret is required")  # pragma: no cover
Example Code

Python & MCP Python SDK
1.25.0
Ngôn ngữ chính
Python
Star
24.3k
Fork
4k
Merge trung bình
1 ngày 19 phút
Pull request đã merge (30 ngày)
29

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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/python-sdk

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

Issue tương tự

Thêm issue về Python

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.