Spring OAUTH2-访问令牌到期时间 [英] Spring OAUTH2 - Access token expiry time

查看:518
本文介绍了Spring OAUTH2-访问令牌到期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式更新/重置访问令牌的到期时间?如果是,那么最好使用哪个类/过滤器,以便可以在JDBC令牌存储中更新到期时间.

Is it possible to update/reset the expiry time of an access token programatically? If yes, which class/filter would be the best place to do it so that expiry time can be updated in JDBC token store.

推荐答案

要全局更新访问令牌的到期时间,您必须创建DefaultTokenServices&实例.像这样注入AuthorizationServerEndpointsConfigurer:

To update the expiry time of an access token globally you should have to create instance of the DefaultTokenServices & inject into the AuthorizationServerEndpointsConfigurer like this :

public AuthorizationServerTokenServices customTokenServices(){
  TokenServices tokenServices = new DefaultTokenServices();
  tokenServices.setReuseAccessToken(reuseAccessToken);
  tokenServices.setTokenStore(tokenStore());
  tokenServices.setSupportRefreshToken(true);
  tokenServices.setAccessTokenValiditySeconds(<seconds>);
  tokenServices.setClientDetailsService(clientDetailsService);
  return tokenServices;
}

&像这样将tokenServices放在AuthorizationServerEndpointsConfigurer中.

& put this tokenServices in AuthorizationServerEndpointsConfigurer like this.

@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
  endpoints.tokenServices(customTokenServices()).
}

这篇关于Spring OAUTH2-访问令牌到期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆