简体   繁体   English

spring oauth2 如何每次获取新的刷新令牌

[英]spring oauth2 how to get a new refresh token every time

When I call refresh token the web service returns a new access token and the old refresh token because the access token has not yet expired.当我调用刷新令牌时,Web 服务返回一个新的访问令牌和旧的刷新令牌,因为访问令牌尚未过期。 Is there any configuration that when I call refresh token this web service return me a new access token and a new refresh token?是否有任何配置可以在我调用刷新令牌时此 Web 服务返回一个新的访问令牌和一个新的刷新令牌?

Spring can be configured not to reuse refresh tokens - by default it reuses -, this should solve the issue. Spring 可以配置为不重用刷新令牌 - 默认情况下它会重用 - 这应该可以解决问题。

@Configuration
public class OAuth2Config extends AuthorizationServerConfigurerAdapter {
    @Override
    public void configure(AuthorizationServerEndpointsConfigurer configurer) throws Exception {
        configurer.reuseRefreshTokens(false);
    }
}

在生成新令牌之前,您可以使用 AOP 通过删除旧令牌或更改其有效时间来使令牌无效,但如果这样做,则将使其他客户端使用的所有刷新令牌无效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM