Authorization Server & Protected Resource Metadata inspection
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 38/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- csharp
调研方向
从 ClientOAuthOptions 以及获取授权服务器和受保护资源元数据的 MCP 客户端路径开始。检查现有的 AuthorizationRedirectDelegate 和相关的身份验证代码,然后比较提议的 delegate 和 ClientOAuthEvents 设计,包括缓存问题。完成的标准是,所选的公共 API 能够一致地提供对所请求元数据的访问,并且为所选 callbacks 提供覆盖。
由索引模型根据 Issue 内容生成。
描述
Sometimes we need access to the AS metadata & PRM. For example, if we want to implement logout we need access to the logout endpoint which resides on the AS metadata, and this AS metadata is already fetched by the MCP client. Another use case is to conditionally inspect the claims in the access token based on the AS that was used for the authentication (e.g getting the user name & display name claims etc.)
a.
One design might be to add a few more delegates to ClientOAuthOptions:
namespace ModelContextProtocol.Authentication;
public sealed class ClientOAuthOptions
{
...
/// <summary>
/// Gets or sets the delegate called when authorization server metadata is retrieved.
/// </summary>
public Action<AuthorizationServerMetadata> OnAuthorizationServerMetadataRetrieved { get; set; }
/// <summary>
/// Gets or sets the delegate called when protected resource metadata is retrieved.
/// </summary>
public Action<ProtectedResourceMetadata> OnProtectedResourceMetadataRetrieved { get; set; }
...
}
Having them as delegates/events avoids having to manage and expose state on the McpClient instance.
b.
Another design might be to use something similar to the pattern in used by ASP.NET Core auth.
namespace ModelContextProtocol.Authentication;
public sealed class RetrievingAuthorizationServerMetadataContext ...;
public sealed class RetrievedAuthorizationServerMetadataContext ...;
public sealed class RetrievingProtectedResourceMetadataContext ...;
public sealed class RetrievedProtectedResourceMetadataContext ...;
public sealed class ClientOAuthEvents
{
/// <summary>
/// Gets or sets the delegate called before authorization server metadata is retrieved.
/// </summary>
public Func<RetrievingAuthorizationServerMetadataContext, Task> OnRetrievingAuthorizationServerMetadata { get; set; } = ...;
/// <summary>
/// Gets or sets the delegate called after authorization server metadata is retrieved.
/// </summary>
public Func<RetrievedAuthorizationServerMetadataContext, Task> OnRetrievedAuthorizationServerMetadata { get; set; } = ...;
/// <summary>
/// Gets or sets the delegate called before protected resource metadata is retrieved.
/// </summary>
public Func<RetrievingProtectedResourceMetadataContext, Task> OnRetrievingProtectedResourceMetadata { get; set; } = ...;
/// <summary>
/// Gets or sets the delegate called after protected resource metadata is retrieved.
/// </summary>
public Func<RetrievedProtectedResourceMetadataContext, Task> OnRetrievedProtectedResourceMetadata { get; set; } = ...;
}
public sealed class ClientOAuthOptions
{
...
/// <summary>
/// Gets or sets the <see cref="ClientOAuthEvents" />.
/// </summary>
public ClientOAuthEvents Events { get; set; } = new();
...
}
The idea behind the "Retrieving" variants is that it allows the user to implement metadata caching, although it also expands the ability for the user to shoot themselves in the foot. I suppose it depends on if caching is a user level concern or a library level concern.
The AuthorizationRedirectDelegate on ClientOAuthOptions can also be moved into the ClientOAuthEvents class to make the surface more uniform.
The overall surface may be reduced if we combine them into a single OnRetrievedMetadata and OnRetrievingMetadata, but trickiness in the contexts I suppose.
- 主要语言
- C#
- 星标
- 4.5k
- 派生
- 814
- 平均合并
- 9 天 19 小时
- 30 天内合并 PR
- 4
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/csharp-sdk 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/csharp-sdk#1867 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
modelcontextprotocol/csharp-sdk#1840 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
modelcontextprotocol/csharp-sdk#1836 ·
-
enhancement needs confirmation
难度 2/5 1-3 小时 新手友好度 64/100
modelcontextprotocol/csharp-sdk#678 · 1 条评论 ·
-
enhancement needs confirmation P3 ready for work
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/csharp-sdk#515 · 6 条评论 · 3 个 reaction ·
查看 modelcontextprotocol/csharp-sdk 的全部 Issue
相似的 Issue
-
area-ai untriaged
难度 2/5 1-3 小时 新手友好度 78/100
dotnet/extensions#7783 ·
-
untriaged
难度 1/5 1 小时以内 新手友好度 88/100
dotnet/dotnet-api-docs#13095 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100
-
type/automation type/tech-debt
难度 2/5 1-3 小时 新手友好度 84/100
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
newrelic/newrelic-dotnet-agent#3850 · 1 条评论 ·