From 36a49879cffb9067728a661dc3423927194114f9 Mon Sep 17 00:00:00 2001 From: Sunrishe Date: Tue, 18 Oct 2022 10:40:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=BA=86spring.mvc.servlet.path=E6=97=B6auth.yml?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maku/framework/security/config/SecurityConfig.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/maku-framework/src/main/java/net/maku/framework/security/config/SecurityConfig.java b/maku-framework/src/main/java/net/maku/framework/security/config/SecurityConfig.java index 4fac4b3..a59baf2 100644 --- a/maku-framework/src/main/java/net/maku/framework/security/config/SecurityConfig.java +++ b/maku-framework/src/main/java/net/maku/framework/security/config/SecurityConfig.java @@ -5,6 +5,7 @@ import net.maku.framework.security.exception.SecurityAuthenticationEntryPoint; import net.maku.framework.security.mobile.MobileAuthenticationProvider; import net.maku.framework.security.mobile.MobileUserDetailsService; import net.maku.framework.security.mobile.MobileVerifyCodeService; +import org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -72,10 +73,14 @@ public class SecurityConfig { } @Bean - SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + SecurityFilterChain filterChain(HttpSecurity http, WebMvcProperties webMvcProperties) + throws Exception { // 忽略授权的地址列表 List permitList = permitResource.getPermitList(); - String[] permits = permitList.toArray(new String[0]); + String servletPrefix = webMvcProperties.getServlet().getServletPrefix(); + String[] permits = permitList.stream() + .map(s -> servletPrefix + (s.charAt(0) == '/' ? "" : '/') + s) + .toArray(String[]::new); http .addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class) -- Gitee