|
|
|
@ -10,9 +10,6 @@ import org.springframework.security.config.annotation.authentication.builders.Au
|
|
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
|
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
|
|
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
|
|
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
@ -23,23 +20,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
*/
|
|
|
|
|
@Configuration
|
|
|
|
|
@EnableWebSecurity
|
|
|
|
|
public class SecurityConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer {
|
|
|
|
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
//private UserDetailsServiceImpl userDetailsService;
|
|
|
|
|
private UserDetailsService userDetailsService;
|
|
|
|
|
private UserDetailsServiceImpl userDetailsService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MyPasswordEncoder passwordEncoder;
|
|
|
|
|
private static final String[] URL_WHITELIST = {
|
|
|
|
|
"/favicon.ico",
|
|
|
|
|
"/webjars/**",
|
|
|
|
|
"/img.icons/**",
|
|
|
|
|
"/swagger-resources/**",
|
|
|
|
|
"/v3/api-docs/**",
|
|
|
|
|
"/swagger-ui/**",
|
|
|
|
|
"/doc.html",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 配置请求路径
|
|
|
|
@ -52,29 +39,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements WebM
|
|
|
|
|
http.headers().frameOptions().disable();
|
|
|
|
|
http.csrf().disable().authorizeRequests()
|
|
|
|
|
.antMatchers("/RSA/publicKey").permitAll()
|
|
|
|
|
.antMatchers("/jmreport/**").anonymous()
|
|
|
|
|
// 配置拦截规则
|
|
|
|
|
.and()
|
|
|
|
|
.authorizeRequests()
|
|
|
|
|
.antMatchers(URL_WHITELIST).permitAll()
|
|
|
|
|
.anyRequest().authenticated();
|
|
|
|
|
}
|
|
|
|
|
@Bean
|
|
|
|
|
@Override
|
|
|
|
|
public AuthenticationManager authenticationManagerBean() throws Exception {
|
|
|
|
|
return super.authenticationManagerBean();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
|
registry.addResourceHandler("/**").addResourceLocations(
|
|
|
|
|
"classpath:/static/");
|
|
|
|
|
registry.addResourceHandler("swagger-ui.html")
|
|
|
|
|
.addResourceLocations("classpath:/META-INF/resources/");
|
|
|
|
|
.antMatchers("/jmreport/**").anonymous();
|
|
|
|
|
|
|
|
|
|
registry.addResourceHandler("/webjars/**")
|
|
|
|
|
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
|
|
|
|
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|