From 65bde3331b367dccfe09f234b3c495e3d5f10857 Mon Sep 17 00:00:00 2001 From: EightMonth Date: Wed, 20 Nov 2024 11:08:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D#7459=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dsas=E5=88=86=E6=94=AF=20@ignoreauth=E6=B3=A8=E8=A7=A3?= =?UTF-8?q?=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/config/security/SecurityConfig.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/SecurityConfig.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/SecurityConfig.java index d2ef0eada..f595bd171 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/SecurityConfig.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/SecurityConfig.java @@ -16,6 +16,7 @@ import org.jeecg.config.security.phone.PhoneGrantAuthenticationConvert; import org.jeecg.config.security.phone.PhoneGrantAuthenticationProvider; import org.jeecg.config.security.social.SocialGrantAuthenticationConvert; import org.jeecg.config.security.social.SocialGrantAuthenticationProvider; +import org.jeecg.config.shiro.ignore.InMemoryIgnoreAuth; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; @@ -42,6 +43,8 @@ import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import org.springframework.security.web.util.matcher.MediaTypeRequestMatcher; +import org.springframework.security.web.util.matcher.RequestMatcher; +import org.springframework.util.CollectionUtils; import org.springframework.web.cors.CorsConfiguration; import java.security.KeyPair; @@ -50,6 +53,7 @@ import java.security.SecureRandom; import java.security.interfaces.ECPrivateKey; import java.security.interfaces.ECPublicKey; import java.util.Arrays; +import java.util.stream.Collectors; /** * spring authorization server核心配置 @@ -102,6 +106,7 @@ public class SecurityConfig { http //设置所有请求都需要认证,未认证的请求都被重定向到login页面进行登录 .authorizeHttpRequests((authorize) -> authorize + .requestMatchers(InMemoryIgnoreAuth.get().stream().map(AntPathRequestMatcher::antMatcher).toList().toArray(new AntPathRequestMatcher[0])).permitAll() .requestMatchers(AntPathRequestMatcher.antMatcher("/sys/cas/client/validateLogin")).permitAll() .requestMatchers(AntPathRequestMatcher.antMatcher("/sys/randomImage/**")).permitAll() .requestMatchers(AntPathRequestMatcher.antMatcher("/sys/checkCaptcha")).permitAll()