Identity Server 4从Db撤消访问令牌

问题描述 投票:1回答:1

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

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

我的理解是,要做到这一点,我需要删除数据库中该用户的持久授权。

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

这是正确的方法吗?

access-token openid-connect identityserver4
1个回答
1
投票

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

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

资料来源: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身份,则可以使用用户锁定:http://www.jamessturtevant.com/posts/ASPNET-Identity-Lockout/

© www.soinside.com 2019 - 2024. All rights reserved.