【问题标题】:Identity Server 4 Revoke access tokens from DbIdentity Server 4 从 Db 撤销访问令牌
【发布时间】:2018-06-01 23:20:17
【问题描述】:

我在 Identity Server 4 的用户存储中构建了一个用于管理用户的 UI。

用户可以锁定他们的帐户,此时我想撤销为该用户保留在数据库中的任何令牌。

据我了解,为此我需要删除数据库中该用户的持久授权。

我在客户端应用程序中使用引用令牌,因此通过删除数据库中的令牌,它将自动取消客户端应用程序中的用户的授权,因为对令牌的引用将无效。

这是解决这个问题的正确方法吗?

【问题讨论】:

    标签: access-token openid-connect identityserver4


    【解决方案1】:

    如果我对您的理解正确,您需要撤销之前颁发给客户的令牌,否则该令牌将在一定时间内保持有效。

    不需要从数据库中删除令牌,Identity Server 4 已经为它提供了一个 API,它实现了RFC 7009。请注意,这应该是从客户端使用的,您需要执行客户端身份验证。

    来源:http://docs.identityserver.io/en/release/endpoints/revocation.html

    您可以使用令牌撤销端点发送撤销请求:

    POST /connect/revocation HTTP/1.1
    Host: server.example.com
    Content-Type: application/x-www-form-urlencoded
    Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
    
    token=45ghiukldjahdnhzdauz&token_type_hint=refresh_token
    

    如果您需要在 Identity Server 4 主机上本地锁定用户并且您正在使用 ASP.NET Identity,您可以使用用户锁定: http://www.jamessturtevant.com/posts/ASPNET-Identity-Lockout/

    【讨论】:

    • in /connect/revocation 请求在Authorization 标头中发送什么?例如,Authorization: Basic {client_secret}?
    • basic Base64Encode(clientId + ':' + clientSecret)
    • 您应该有权拨打电话吗?谁可以或不能撤销?
    • 发送client_idclient_secret作为参数,则不需要Basic的授权。
    猜你喜欢
    • 1970-01-01
    • 2019-04-12
    • 2020-09-29
    • 1970-01-01
    • 2015-03-06
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多