引用令牌是否需要刷新令牌?
Are refresh tokens necessary with reference tokens?
我们有一个 Web API 使用本地 API 身份验证通过 IdentityServer4 进行保护。我们目前同时使用 Reference Tokens 和 Refresh Tokens。既然我们有能力随时撤销引用令牌,我们是否有必要使用刷新令牌?难道我们不能为参考令牌设置一个很长的有效期吗?这种方法有任何安全隐患吗?
When using reference tokens - IdentityServer will store the contents
of the token in a data store and will only issue a unique identifier
for this token back to the client. The API receiving this reference
must then open a back-channel communication to IdentityServer to
validate the token.
换句话说,客户端不必向 api 提供访问令牌,只需传递引用即可。
这是 JWT 令牌和参考令牌之间的一个很大区别。客户端向 API 发送必须由 API 信任的 JWT 令牌,而无需咨询提供者,而引用令牌强制 API 联系提供者,而不必依赖客户。
来自Refresh Tokens documentation:
Since access tokens have finite lifetimes, refresh tokens allow
requesting new access tokens without user interaction.
现在的问题是,引用令牌会过期吗?不是来自它本身,因为它不包含任何逻辑,这与 JWT 令牌不同。但是可能有一个服务器端设置触发某种过期,或者实际上导致引用被撤销。
无论哪种方式,在这种情况下刷新令牌都没有用。因为您无法刷新参考令牌。引用令牌存在或不存在(无效或已被撤销)。
我们有一个 Web API 使用本地 API 身份验证通过 IdentityServer4 进行保护。我们目前同时使用 Reference Tokens 和 Refresh Tokens。既然我们有能力随时撤销引用令牌,我们是否有必要使用刷新令牌?难道我们不能为参考令牌设置一个很长的有效期吗?这种方法有任何安全隐患吗?
When using reference tokens - IdentityServer will store the contents of the token in a data store and will only issue a unique identifier for this token back to the client. The API receiving this reference must then open a back-channel communication to IdentityServer to validate the token.
换句话说,客户端不必向 api 提供访问令牌,只需传递引用即可。
这是 JWT 令牌和参考令牌之间的一个很大区别。客户端向 API 发送必须由 API 信任的 JWT 令牌,而无需咨询提供者,而引用令牌强制 API 联系提供者,而不必依赖客户。
来自Refresh Tokens documentation:
Since access tokens have finite lifetimes, refresh tokens allow requesting new access tokens without user interaction.
现在的问题是,引用令牌会过期吗?不是来自它本身,因为它不包含任何逻辑,这与 JWT 令牌不同。但是可能有一个服务器端设置触发某种过期,或者实际上导致引用被撤销。
无论哪种方式,在这种情况下刷新令牌都没有用。因为您无法刷新参考令牌。引用令牌存在或不存在(无效或已被撤销)。