JWT 存储 token 通过 Nacos OpenFeign 实现远程调用
This commit is contained in:
		@@ -48,6 +48,7 @@ public class OAuth2Configuration extends AuthorizationServerConfigurerAdapter {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
 | 
			
		||||
        endpoints
 | 
			
		||||
//                .allowedTokenEndpointRequestMethods()
 | 
			
		||||
                .tokenServices(serverTokenServices())   //设定为刚刚配置好的AuthorizationServerTokenServices
 | 
			
		||||
                .userDetailsService(service)
 | 
			
		||||
                .authenticationManager(manager);
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,8 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 | 
			
		||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
 | 
			
		||||
import org.springframework.security.core.userdetails.UserDetailsService;
 | 
			
		||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 | 
			
		||||
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
 | 
			
		||||
import org.springframework.security.crypto.password.PasswordEncoder;
 | 
			
		||||
import org.springframework.security.oauth2.provider.token.TokenStore;
 | 
			
		||||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
 | 
			
		||||
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
 | 
			
		||||
@@ -59,4 +61,9 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
 | 
			
		||||
    public TokenStore tokenStore(JwtAccessTokenConverter converter) {  //Token存储方式现在改为JWT存储
 | 
			
		||||
        return new JwtTokenStore(converter);  //传入刚刚定义好的转换器
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
//    @Bean
 | 
			
		||||
//    public PasswordEncoder passwordEncoder() {
 | 
			
		||||
//        return NoOpPasswordEncoder.getInstance();
 | 
			
		||||
//    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user