modelcontextprotocol / modelcontextprotocol/python-sdk
ClientAuthenticator ignores token_endpoint_auth_method="none" when client_secret is stored
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 24.3k
- Fork
- 4k
- Merge trung bình
- 1 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 31
Mô tả
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
ClientAuthenticator behavior is only partially honoring token_endpoint_auth_method="none":
Essentially:
token_endpoint_auth_method="none"=> skip extracting credentials from the request (correct)client.client_secretexists => 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
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.
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.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- authentication
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 72/100