【问题标题】:Custom flow - delegation自定义流程 - 委托
【发布时间】:2021-07-17 05:03:19
【问题描述】:

我想知道是否可以用openiddict 实现一种委托授权类型,类似于用Identity Server 实现的here

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

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

【问题讨论】:

    标签: openiddict


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 谢谢凯文!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-12
    • 2021-08-29
    • 2020-03-23
    • 2011-04-17
    • 1970-01-01
    相关资源
    最近更新 更多