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

[Client] Inject Bearer token into HttpTransport requests + handle 401 re-auth

Đang mở
#316 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, backend

Hướng nghiên cứu

Bắt đầu trong src/Client/Transport/HttpTransport.php và xem xét dependency TokenStorageInterface từ #315. Theo dõi send() và entry point của authentication coordinator, sau đó bổ sung unit test coverage cho việc chèn Bearer header và một lần retry re-auth duy nhất khi nhận 401. Hoàn tất khi các request sử dụng endpoint token hiện tại, response 401 kích hoạt đúng một lần retry và extension point AuthCoordinator được ghi lại trong tài liệu.

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

Once an access token is acquired (via any OAuth grant), every outbound JSON-RPC request on HttpTransport must carry Authorization: Bearer <token>. On a 401 Unauthorized mid-session, the transport must trigger a re-auth attempt and retry the failed request exactly once.

Scope

  • src/Client/Transport/HttpTransport.php:
    • Read current token from TokenStorageInterface keyed by endpoint URL.
    • Add Authorization: Bearer <token> header on send() when a token is present.
    • On 401, parse WWW-Authenticate header, invoke auth coordinator, retry once.
  • Introduce Mcp\Client\Auth\AuthCoordinator to orchestrate discovery → registration → token acquisition. (Implementation details land in dependent issues.)

Conformance scenarios unblocked

All auth/* scenarios depend on this wiring.

Dependencies

Blocked by: #315 (TokenStorageInterface).

Acceptance

  • Unit tests for header injection + 401 retry behavior.
  • Documented extension point for AuthCoordinator.

cc @soyuka

Ngôn ngữ chính
PHP
Star
1.6k
Fork
173
Merge trung bình
2 ngày 20 giờ
Pull request đã merge (30 ngày)
14

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.