我开始使用 ASOS (AspNet.Security.OpenIdConnect.Server) 框架进行基于 token 的身份验证。
我已经完成了访问 token 的生成和检索,现在正在转向刷新 token 位。
我的问题是:
当然,他们可以去 token 端点同时获取新的访问 token 和刷新 token ,但是那个 clientID 的其他实例呢?假设它们的代码相同(即它们不共享刷新 token 的知识),每个实例也将继续请求新的访问和刷新 token 。
另外,撤销刷新 token 的常见过程是什么?
是否就像从存储它的任何地方删除它一样简单?
谢谢。
最佳答案
Should I just store the clientID and the hashed and salted refresh token in a database (Along with utility fields, such as an expiration date)?
我推荐的方法是使用 ASOS 附加到它创建的所有 token 的票证标识符。您可以从
SerializeRefreshToken
中检索刷新 token 标识符和到期日期。事件来自 context.Ticket.GetTokenId()
和 context.Ticket.ExpiresUtc
.注意:默认标识符是 GUID,但您可以使用
context.Ticket.SetTokenId("token identifier")
替换它.Specifically, I mean what if 1 of the client's access tokens expires, but their refresh token has also expired? Of course they can go to the token endpoint to get a new access token and refresh token at the same time, but then what about the other instances for that clientID?
这实际上取决于您的应用程序要求以及您如何实现它。您可以自由地将刷新 token 视为完全独立的,或者相反,相互依赖。这个逻辑通常会发生在
HandleTokenRequest
中。 .Also, what is the common process of revoking the refresh tokens? Is it as simple as just deleting it from wherever you're storing it?
如果您使用默认 token 格式(超过推荐的格式),刷新 token 将被视为有效,直到它们过期。由您来检查 token 是否已从
HandleTokenRequest
撤销通过进行数据库查找(您可以使用 context.Ticket.GetTokenId()
获取刷新 token 标识符)
关于asp.net-web-api - 刷新 token - 多个客户端的服务器端存储和撤销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38815971/