问题描述
我想知道是否可以使用 openiddict
实现类似于使用 Identity Server
实现的 here 的委托授权类型。
var result = await _validator.ValidateAccesstokenAsync(userToken);
if (result.IsError)
{
context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant);
return;
}
是否有任何与 ValidateAccesstokenAsync
中的 openiddict
等效的方法来验证令牌并访问其某些属性?
解决方法
标准代币交换的实施由 https://github.com/openiddict/openiddict-core/issues/1249 跟踪。
与此同时,您可以覆盖默认的 2015-04-23 00:01:00
处理程序以处理您的自定义授权并从您使用的客户参数中提取访问令牌:
然后,您可以使用 ValidateTokenParameter
的实例调用 IOpenIddictServerDispatcher.DispatchAsync()
方法来触发身份验证事件。如果 ProcessAuthenticationContext
是 IsRejected
,这意味着令牌无效。否则,您将能够访问其声明主体。