首页 > 解决方案 > 自定义流程 - 委托

问题描述

我想知道是否可以使用openiddict类似于此处实现的委托授权类型来实现Identity Server.

var result = await _validator.ValidateAccessTokenAsync(userToken);
if (result.IsError)
{
    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant);
    return;
}

是否有任何等效ValidateAccessTokenAsync的方法来openiddict验证令牌并访问其某些属性?

标签: openiddict

解决方案


https://github.com/openiddict/openiddict-core/issues/1249跟踪标准令牌交换的实施。

同时,您可以覆盖默认ValidateTokenParameter处理程序以使用您的自定义授权并从您使用的客户参数中提取访问令牌:

https://github.com/openiddict/openiddict-core/blob/422d8979adb8cdbc6c8c8e14faa1d736208271e/src/OpenIddict.Server/OpenIddictServerHandlers.cs#L168

IOpenIddictServerDispatcher.DispatchAsync()然后,您可以使用 的实例调用该方法ProcessAuthenticationContext来触发身份验证事件。如果IsRejectedtrue,这意味着令牌无效。否则,您将能够访问其声明主体。


推荐阅读