[Client] Implement client_credentials grant (client_secret_basic + private_key_jwt)

Đang mở
#324 0 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
php
Lĩnh vực
api, authentication, security

Hướng nghiên cứu

Bắt đầu bằng việc đọc phần công việc đang bị chặn trong #318 cho token_endpoint và #321 cho auth methods, sau đó kiểm tra Mcp\Client\Auth\Grant\ClientCredentialsGrant và các điểm cấu hình OAuth client của Builder được nêu ở đây. Chạy hoặc bổ sung coverage cho auth/client-credentials-basic và auth/client-credentials-jwt, bao gồm cả việc xác minh bằng public key của fixture. Công việc được xem là hoàn tất khi cả hai dạng xác thực đều vượt qua unit tests và quyết định về dependency JWT được ghi lại trong phần mô tả PR.

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

Mô tả

auth Client enhancement improves spec compliance

Context

For non-interactive / machine-to-machine MCP clients, the client_credentials grant (RFC 6749 §4.4) is used directly against token_endpoint. Two client authentication shapes are required by conformance:

  • Basic: Authorization: Basic base64(client_id:client_secret) + body grant_type=client_credentials.
  • JWT assertion (private_key_jwt, RFC 7521/7523): body client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer + client_assertion=<signed JWT>. JWT signed with the client's private key (ES256/RS256), iss+sub=client_id, aud=token_endpoint, jti=random, exp=now+60s.

Scope

  • Mcp\Client\Auth\Grant\ClientCredentialsGrant with pluggable assertion signer.
  • JWT signing: prefer a thin built-in using openssl_sign to avoid heavy deps; if dep is preferred, choose lcobucci/jwt (modern, typed) over firebase/php-jwt.
  • Configure via Builder::setOAuthClient($id, $secret) or Builder::setOAuthClientWithKey($id, $privateKeyPem, $algorithm).

Conformance scenarios unblocked

auth/client-credentials-basic, auth/client-credentials-jwt.

Dependencies

Blocked by: #318 (token_endpoint), #321 (auth methods).

Acceptance

  • Unit tests for both shapes; JWT signing verified against a fixture public key.
  • Decision on JWT dep documented in PR description.

cc @soyuka

Ngôn ngữ chính
PHP
Star
1.6k
Fork
173
Merge trung bình
2 ngày 49 phút
Pull request đã merge (30 ngày)
23

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

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

Issue tương tự

Thêm issue về PHP

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.