[Client] Inject Bearer token into HttpTransport requests + handle 401 re-auth
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ả
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
TokenStorageInterfacekeyed by endpoint URL. - Add
Authorization: Bearer <token>header onsend()when a token is present. - On
401, parseWWW-Authenticateheader, invoke auth coordinator, retry once.
- Read current token from
- Introduce
Mcp\Client\Auth\AuthCoordinatorto 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
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.
Issue khác của modelcontextprotocol/php-sdk
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStan Đang mởServer
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/php-sdk#468 · 2 bình luận ·
-
needs confirmation needs maintainer action Server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/php-sdk#398 · 1 reaction ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/php-sdk#370 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
modelcontextprotocol/php-sdk#513 ·
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
modelcontextprotocol/php-sdk#510 · 1 bình luận ·
Tất cả issue của modelcontextprotocol/php-sdk
Issue tương tự
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/safe-publish#594 ·
-
needs-triage Platform(Default)
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
HttpClient
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
symfony/symfony-docs#23092 ·
-
sync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
sync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100