|
@ -1,6 +1,7 @@
|
|
package com.yihu.base.security.config;
|
|
package com.yihu.base.security.config;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.yihu.base.security.properties.AccessTokenPorperties;
|
|
import com.yihu.base.security.rbas.ClientServiceProvider;
|
|
import com.yihu.base.security.rbas.ClientServiceProvider;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
@ -41,6 +42,8 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
|
private PasswordEncoder passwordEncoder;
|
|
private PasswordEncoder passwordEncoder;
|
|
@Autowired
|
|
@Autowired
|
|
private DataSource dataSource;
|
|
private DataSource dataSource;
|
|
|
|
@Autowired
|
|
|
|
private AccessTokenPorperties accessTokenPorperties;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@ -76,12 +79,15 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
|
oAuth2AuthenticationManager.setTokenServices(defaultTokenServices());
|
|
oAuth2AuthenticationManager.setTokenServices(defaultTokenServices());
|
|
return oAuth2AuthenticationManager;
|
|
return oAuth2AuthenticationManager;
|
|
}
|
|
}
|
|
|
|
|
|
//==========================token相关配置=================================
|
|
//==========================token相关配置=================================
|
|
@Bean
|
|
@Bean
|
|
@Primary
|
|
@Primary
|
|
DefaultTokenServices defaultTokenServices() {
|
|
DefaultTokenServices defaultTokenServices() {
|
|
DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
|
|
DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
|
|
defaultTokenServices.setTokenStore(tokenStore());
|
|
defaultTokenServices.setTokenStore(tokenStore());
|
|
|
|
defaultTokenServices.setAccessTokenValiditySeconds(60 * 60 * accessTokenPorperties.getAccessTokenValiditySeconds()); //默认2小时
|
|
|
|
defaultTokenServices.setRefreshTokenValiditySeconds(60 * 60 * accessTokenPorperties.getRefreshTokenValiditySeconds());//默认2小时
|
|
return defaultTokenServices;
|
|
return defaultTokenServices;
|
|
}
|
|
}
|
|
|
|
|