This commit is contained in:
ran.shang
2026-04-13 11:12:59 +08:00
parent 1f52669b52
commit 4bd6b57b4f

View File

@@ -18,6 +18,7 @@ import org.springframework.security.web.access.intercept.FilterInvocationSecurit
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; import org.springframework.security.web.authentication.AnonymousAuthenticationFilter;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.senmesh.security.access.intercept.FilterSecurityInterceptor; import com.senmesh.security.access.intercept.FilterSecurityInterceptor;
@@ -151,7 +152,7 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
// 禁用CSRF // 禁用CSRF
// http.csrf().disable(); // http.csrf().disable();
http.csrf(c -> c.ignoringAntMatchers("/login")) // 登录接口免 CSRF http.csrf(c -> c.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).ignoringAntMatchers("/login")) // 登录接口免 CSRF
; ;
http.headers().frameOptions().deny(); http.headers().frameOptions().deny();
http.headers().xssProtection().block(true); http.headers().xssProtection().block(true);