【问题标题】:Identityserver4 Revoke One or All tokensIdentityserver4 撤销一个或所有令牌
【发布时间】:2018-06-02 03:03:20
【问题描述】:

在应用程序中,当用户注销时,我会撤销当前会话的引用和刷新令牌。这是一个 API,因此其他设备可以登录到应用程序中。我想提供从所有设备注销或注销的功能。

在 Identityserver4 中,当我们注销时,我们可以使用撤销客户端来撤销一个令牌:

var client = new TokenRevocationClient(...);
//var result = await client.RevokeAccessTokenAsync(token);
//var result = await client.RevokeRefreshTokenAsync(token);

这反过来又调用IReferenceTokenStore.RemoveReferenceTokenAsync(string handle)

现在的问题是,我将如何为用户撤销 所有 令牌?这意味着它应该调用IReferenceTokenStore.RemoveReferenceTokensAsync(string subjectId, string clientId)

【问题讨论】:

  • 我遇到了完全相反的问题,请参阅link。我想撤销单个会话/令牌,但没有可用的令牌,只有 AccountController.LogOut 方法中的 logoutid ...在您在注销时有特定令牌可用的情况下,您在 IdSrv4 的哪个位置调用了 TokenRevocationClient?

标签: asp.net-core identityserver4


【解决方案1】:

您可以注入IIdentityServerInteractionService 的实例并调用RevokeTokensForCurrentSessionAsync()

这应该会导致调用IReferenceTokenStore.RemoveReferenceTokensAsync(string subjectId, string clientId)

【讨论】:

    猜你喜欢
    • 2021-07-05
    • 2020-02-20
    • 2021-06-28
    • 1970-01-01
    • 2017-06-15
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多