Browse Source

Merge remote-tracking branch 'origin/online1' into online1

Joburgess 4 năm trước cách đây
mục cha
commit
dd01e93aae

+ 7 - 1
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/config/AuthorizationServerConfig.java

@@ -53,6 +53,11 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 	@Override
 	public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
 
+		clients.withClientDetails(jdbcClientDetailsService());
+	}
+
+	@Bean
+	public JdbcClientDetailsService jdbcClientDetailsService() {
 		JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
 
 		clientDetailsService
@@ -60,7 +65,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 		clientDetailsService
 				.setFindClientDetailsSql("select id_, CONCAT('{noop}',client_secret_) as client_secret, resource_ids_, scope_, authorized_grant_types_, web_server_redirect_uri_, authorities_, access_token_validity_, refresh_token_validity_, additional_information_, autoapprove_ from sys_oauth_client_details order by id_");
 
-		clients.withClientDetails(clientDetailsService);
+		return clientDetailsService;
 	}
 
 	@Bean
@@ -77,6 +82,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 		CustomTokenServices tokenServices = new CustomTokenServices();
 		tokenServices.setTokenStore(redisTokenStore());
 		tokenServices.setSupportRefreshToken(true);
+		tokenServices.setClientDetailsService(jdbcClientDetailsService());
 		//tokenServices.setAccessTokenValiditySeconds(60 * 60 * 24); // token有效期自定义设置,默认12小时
 		//tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 24 * 30);// 默认30天,这里修改
 		return tokenServices;