|  | @ -5,26 +5,19 @@ import com.yihu.base.security.properties.AccessTokenPorperties;
 | 
	
		
			
				|  |  | import com.yihu.base.security.properties.SecurityProperties;
 | 
	
		
			
				|  |  | import com.yihu.base.security.rbas.ClientServiceProvider;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Qualifier;
 | 
	
		
			
				|  |  | import org.springframework.context.annotation.Bean;
 | 
	
		
			
				|  |  | import org.springframework.context.annotation.Configuration;
 | 
	
		
			
				|  |  | import org.springframework.context.annotation.Primary;
 | 
	
		
			
				|  |  | import org.springframework.data.redis.connection.RedisConnectionFactory;
 | 
	
		
			
				|  |  | import org.springframework.security.authentication.AuthenticationManager;
 | 
	
		
			
				|  |  | import org.springframework.security.core.userdetails.UserDetailsService;
 | 
	
		
			
				|  |  | import org.springframework.security.crypto.password.PasswordEncoder;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.common.OAuth2AccessToken;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.ClientDetailsService;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.expression.OAuth2WebSecurityExpressionHandler;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.token.TokenStore;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -46,8 +39,6 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PasswordEncoder passwordEncoder;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DataSource dataSource;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private AccessTokenPorperties accessTokenPorperties;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -62,7 +53,11 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 | 
	
		
			
				|  |  |         endpoints.authenticationManager(oAuth2AuthenticationManager())
 | 
	
		
			
				|  |  |                 .tokenStore(tokenStore())
 | 
	
		
			
				|  |  |                 .userDetailsService(userDetailsService)
 | 
	
		
			
				|  |  |                 .tokenServices(defaultTokenServices());
 | 
	
		
			
				|  |  |                 .tokenServices(defaultTokenServices())
 | 
	
		
			
				|  |  |                // .pathMapping("/oauth/confirm_access", "/extenal/oauth/confirm_access");//授权码模式  授权页面转换
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         ;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //endpoints.setClientDetailsService(clientDetailsService);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -71,7 +66,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 | 
	
		
			
				|  |  |     public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
 | 
	
		
			
				|  |  |         //.jdbc(dataSource).passwordEncoder(passwordEncoder) .clients(clientDetailsService)
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         clients.withClientDetails(clientDetailsService) ;
 | 
	
		
			
				|  |  |         clients.withClientDetails(clientDetailsService);
 | 
	
		
			
				|  |  |         ;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -99,6 +94,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 | 
	
		
			
				|  |  |         defaultTokenServices.setTokenStore(tokenStore());
 | 
	
		
			
				|  |  |         defaultTokenServices.setAccessTokenValiditySeconds(60 * 60 * accessTokenPorperties.getAccessTokenValidityHours()); //默认2小时
 | 
	
		
			
				|  |  |         defaultTokenServices.setRefreshTokenValiditySeconds(60 * 60 * accessTokenPorperties.getRefreshTokenValidityHours());//默认2小时
 | 
	
		
			
				|  |  |         defaultTokenServices.setClientDetailsService(clientDetailsService);
 | 
	
		
			
				|  |  |         return defaultTokenServices;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -107,7 +103,6 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 | 
	
		
			
				|  |  |     TokenStore tokenStore() {
 | 
	
		
			
				|  |  |         RedisTokenStore redisTokenStore = new RedisTokenStore(redisConnectionFactory);
 | 
	
		
			
				|  |  |         redisTokenStore.setPrefix(SecurityProperties.prefix_accesstoken);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return redisTokenStore;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |