|
@@ -4,7 +4,11 @@ import com.jiayue.ssi.filter.*;
|
|
|
import com.jiayue.ssi.handler.*;
|
|
|
import com.jiayue.ssi.service.impl.UserServiceImpl;
|
|
|
import com.jiayue.ssi.util.JwtTokenUtil;
|
|
|
+import org.apache.catalina.connector.Connector;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
|
|
|
+import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
|
|
+import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.http.HttpMethod;
|
|
@@ -19,6 +23,8 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
|
import org.springframework.security.web.authentication.logout.LogoutFilter;
|
|
|
+import org.springframework.security.web.firewall.DefaultHttpFirewall;
|
|
|
+import org.springframework.security.web.firewall.HttpFirewall;
|
|
|
import org.springframework.web.filter.CorsFilter;
|
|
|
|
|
|
|
|
@@ -58,6 +64,10 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
// 明文+随机盐值》加密存储
|
|
|
return new BCryptPasswordEncoder();
|
|
|
}
|
|
|
+ @Bean
|
|
|
+ public HttpFirewall allowUrlEncodedSlashHttpFirewall(){
|
|
|
+ return new DefaultHttpFirewall();
|
|
|
+ }
|
|
|
|
|
|
// @Override
|
|
|
// protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
|
@@ -74,7 +84,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
httpSecurity.addFilterBefore(new VerifyCodeFilter(), LogoutFilter.class);
|
|
|
httpSecurity.addFilterBefore(new MailCodeFilter(), LogoutFilter.class);
|
|
|
httpSecurity.addFilterBefore(new JwtAuthenticationTokenFilter(userServiceImpl, jwtTokenUtil), LogoutFilter.class);
|
|
|
- httpSecurity.headers().frameOptions().sameOrigin();
|
|
|
+ httpSecurity.headers().frameOptions().disable();
|
|
|
+// httpSecurity.headers().httpStrictTransportSecurity().includeSubDomains(true).preload(true).maxAgeInSeconds(31536000);
|
|
|
httpSecurity
|
|
|
// 由于使用的是JWT,我们这里不需要csrf
|
|
|
.csrf().disable()
|
|
@@ -97,6 +108,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
//针对静态资源放行
|
|
|
@Override
|
|
|
public void configure(WebSecurity web) throws Exception {
|
|
|
+ web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
|
|
|
/*super.configure(web);*/
|
|
|
web.ignoring().antMatchers("/static/**", "/assets/**","/getVerifyCode","/getMailCode","/sysParameterController/getUseSendMail", "/");
|
|
|
}
|