gpt4 book ai didi

spring - 多个访问 token 和一个刷新 token

转载 作者:行者123 更新时间:2023-12-03 20:28:20 25 4
gpt4 key购买 nike

我有多个移动客户端,它们都使用密码授予流程进行身份验证。为此,我只想使用一个非常持久的刷新 token 和多个短期访问 token 。我一直在尝试在 Spring 使用 Password Grant 生成多个访问 token ,但是,每当我刷新访问 token 时,旧的访问 token 就会停止工作。我检查了数据库,对于该特定身份验证,oauth_access_token 表中始终只有一条记录。 Spring Oauth2 不是应该为一个刷新 token 生成多个访问 token 吗?
感谢您的帮助。

最佳答案

OAuth2 规范支持它,见 RFC 6749 :

1.5. Refresh Token

Refresh tokens are credentials used to obtain access tokens. Refreshtokens are issued to the client by the authorization server and areused to obtain a new access token when the current access tokenbecomes invalid or expires, or to obtain additional access tokenswith identical or narrower scope (access tokens may have a shorterlifetime and fewer permissions than authorized by the resourceowner).


但是 Spring Security OAuth2 不支持,见 DefaultTokenServices#refreshAccessToken :
  // clear out any access tokens already associated with the refresh
// token.
tokenStore.removeAccessTokenUsingRefreshToken(refreshToken);

TokenStore#removeAccessTokenUsingRefreshToken :

Remove an access token using a refresh token. This functionality is necessary so refresh tokens can't be used to create an unlimited number of access tokens.


一种解决方法是实现自定义 TokenStore .

关于spring - 多个访问 token 和一个刷新 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56103373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com