|
@@ -87,12 +87,16 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
httpSecurity
|
|
httpSecurity
|
|
|
// CSRF禁用,因为不使用session
|
|
// CSRF禁用,因为不使用session
|
|
|
.csrf().disable()
|
|
.csrf().disable()
|
|
|
|
|
+ // 允许跨域预检请求
|
|
|
|
|
+ .cors().and()
|
|
|
// 认证失败处理类
|
|
// 认证失败处理类
|
|
|
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
|
|
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
|
|
|
// 基于token,所以不需要session
|
|
// 基于token,所以不需要session
|
|
|
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
|
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
|
|
// 过滤请求
|
|
// 过滤请求
|
|
|
.authorizeRequests()
|
|
.authorizeRequests()
|
|
|
|
|
+ // 放行 OPTIONS 预检请求
|
|
|
|
|
+ .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
|
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
|
|
.antMatchers("/login", "/register", "/captchaImage").anonymous()
|
|
.antMatchers("/login", "/register", "/captchaImage").anonymous()
|
|
|
.antMatchers(
|
|
.antMatchers(
|