[Client] Implement client_credentials grant (client_secret_basic + private_key_jwt)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- php
- 领域
- api, authentication, security
调研方向
先阅读 #318 中关于 token_endpoint 和 #321 中关于 auth methods 的阻塞工作,然后检查 Mcp\Client\Auth\Grant\ClientCredentialsGrant 以及此处提到的 Builder OAuth 客户端配置点。运行或补充 auth/client-credentials-basic 和 auth/client-credentials-jwt 的覆盖,包括使用 fixture 公钥进行验证。完成的标准是两种身份验证形式都通过单元测试,并且在 PR 描述中记录 JWT 依赖项的决策。
由索引模型根据 Issue 内容生成。
描述
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)+ bodygrant_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\ClientCredentialsGrantwith pluggable assertion signer.- JWT signing: prefer a thin built-in using
openssl_signto avoid heavy deps; if dep is preferred, chooselcobucci/jwt(modern, typed) overfirebase/php-jwt. - Configure via
Builder::setOAuthClient($id, $secret)orBuilder::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
- 主要语言
- PHP
- 星标
- 1.6k
- 派生
- 173
- 平均合并
- 2 天 49 分钟
- 30 天内合并 PR
- 23
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/php-sdk 的其他 Issue
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStan 未关闭Server
难度 1/5 1 小时以内 新手友好度 78/100
modelcontextprotocol/php-sdk#468 · 2 条评论 ·
-
needs confirmation needs maintainer action Server
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/php-sdk#398 · 1 个 reaction ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/php-sdk#370 ·
-
enhancement
难度 4/5 3-5 天 新手友好度 55/100
modelcontextprotocol/php-sdk#510 · 1 条评论 ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
modelcontextprotocol/php-sdk#504 ·
查看 modelcontextprotocol/php-sdk 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
getgrav/grav-plugin-api#45 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
RSS-Bridge/rss-bridge#5098 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
phingofficial/phing#2025 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
silverstripe/developer-docs#911 ·
-
难度 2/5 1-3 小时 新手友好度 74/100