update 优化 springboot 3.5 新特性与过期代码

This commit is contained in:
疯狂的狮子Li
2025-07-30 16:10:00 +08:00
parent 89f9617ccb
commit f47bd39644
5 changed files with 9 additions and 80 deletions

View File

@ -12,6 +12,7 @@ import org.springframework.security.config.annotation.web.configurers.HeadersCon
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
/**
@ -30,7 +31,7 @@ public class SecurityConfig {
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity httpSecurity, MvcRequestMatcher.Builder mvc) throws Exception {
public SecurityFilterChain filterChain(HttpSecurity httpSecurity, PathPatternRequestMatcher.Builder mvc) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl(adminContextPath + "/");
@ -40,8 +41,8 @@ public class SecurityConfig {
header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
.authorizeHttpRequests((authorize) ->
authorize.requestMatchers(
mvc.pattern(adminContextPath + "/assets/**"),
mvc.pattern(adminContextPath + "/login")
mvc.matcher(adminContextPath + "/assets/**"),
mvc.matcher(adminContextPath + "/login")
).permitAll()
.anyRequest().authenticated())
.formLogin((formLogin) ->