|
|
|
@ -42,34 +42,34 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
// 禁用 csrf, 由于使用的是JWT,我们这里不需要csrf
|
|
|
|
// 禁用 csrf, 由于使用的是JWT,我们这里不需要csrf
|
|
|
|
// http.cors().and().csrf().disable()
|
|
|
|
http.cors().and().csrf().disable() |
|
|
|
// .authorizeRequests()
|
|
|
|
.authorizeRequests() |
|
|
|
// // 跨域预检请求
|
|
|
|
// 跨域预检请求
|
|
|
|
// .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
|
|
|
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll() |
|
|
|
// // web jars
|
|
|
|
// web jars
|
|
|
|
// .antMatchers("/webjars/**").permitAll()
|
|
|
|
.antMatchers("/webjars/**").permitAll() |
|
|
|
// // 查看SQL监控(druid)
|
|
|
|
// 查看SQL监控(druid)
|
|
|
|
// .antMatchers("/druid/**").permitAll()
|
|
|
|
// .antMatchers("/druid/**").permitAll()
|
|
|
|
// // 首页和登录页面
|
|
|
|
// 首页和登录页面
|
|
|
|
// .antMatchers("/").permitAll()
|
|
|
|
.antMatchers("/").permitAll() |
|
|
|
// .antMatchers("/login").permitAll()
|
|
|
|
.antMatchers("/login").permitAll() |
|
|
|
// // swagger
|
|
|
|
// swagger
|
|
|
|
// .antMatchers("/swagger-ui.html").permitAll()
|
|
|
|
// .antMatchers("/swagger-ui.html").permitAll()
|
|
|
|
// .antMatchers("/swagger-resources/**").permitAll()
|
|
|
|
// .antMatchers("/swagger-resources/**").permitAll()
|
|
|
|
// .antMatchers("/v2/api-docs").permitAll()
|
|
|
|
// .antMatchers("/v2/api-docs").permitAll()
|
|
|
|
// .antMatchers("/webjars/springfox-swagger-ui/**").permitAll()
|
|
|
|
// .antMatchers("/webjars/springfox-swagger-ui/**").permitAll()
|
|
|
|
// // 验证码
|
|
|
|
// 验证码
|
|
|
|
// .antMatchers("/captcha.jpg**").permitAll()
|
|
|
|
.antMatchers("/captcha.jpg**").permitAll() |
|
|
|
// // 服务监控
|
|
|
|
// 服务监控
|
|
|
|
// .antMatchers("/actuator/**").permitAll()
|
|
|
|
.antMatchers("/actuator/**").permitAll() |
|
|
|
// // 其他所有请求需要身份认证
|
|
|
|
// 其他所有请求需要身份认证
|
|
|
|
// .anyRequest().authenticated();
|
|
|
|
.anyRequest().authenticated(); |
|
|
|
// // 退出登录处理器
|
|
|
|
// 退出登录处理器
|
|
|
|
// http.logout().logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler());
|
|
|
|
http.logout().logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()); |
|
|
|
// // token验证过滤器
|
|
|
|
// token验证过滤器
|
|
|
|
// http.addFilterBefore(new JwtAuthenticationFilter(authenticationManager()), UsernamePasswordAuthenticationFilter.class);
|
|
|
|
http.addFilterBefore(new JwtAuthenticationFilter(authenticationManager()), UsernamePasswordAuthenticationFilter.class); |
|
|
|
// 禁用token验证
|
|
|
|
// 禁用token验证
|
|
|
|
http.csrf().disable().authorizeRequests().anyRequest().permitAll().and().logout().permitAll(); |
|
|
|
// http.csrf().disable().authorizeRequests().anyRequest().permitAll().and().logout().permitAll();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
|