From 7fd2ef7e8a754652283090dbbec28fea27a712b4 Mon Sep 17 00:00:00 2001 From: huqingchun Date: Sat, 25 Nov 2023 10:13:02 +0800 Subject: [PATCH] =?UTF-8?q?#I8I2EW=20=E4=BF=AE=E5=A4=8D@PermitAll=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98,=20=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=EF=BC=9A@PermitAll=E6=B3=A8=E8=A7=A3=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=9A=84@RequestMapping=E6=9C=AA=E6=8C=87=E5=AE=9Amet?= =?UTF-8?q?hod=E6=97=B6=EF=BC=8CPermitAll=E9=85=8D=E7=BD=AE=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=EF=BC=8C=20=E8=A7=A3=E5=86=B3=E6=96=B9?= =?UTF-8?q?=E6=A1=88=EF=BC=9A=E6=9C=AA=E6=8C=87=E5=AE=9Amethod=E6=97=B6?= =?UTF-8?q?=E5=B0=864=E4=B8=AA=E8=AF=B7=E6=B1=82=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=9D=87=E5=8A=A0=E5=85=A5result=20=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/YudaoWebSecurityConfigurerAdapter.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java index 24ba15ac0..08f3c505a 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java @@ -17,6 +17,7 @@ import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.access.AccessDeniedHandler; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; @@ -160,8 +161,16 @@ public class YudaoWebSecurityConfigurerAdapter { continue; } Set urls = entry.getKey().getPatternsCondition().getPatterns(); + //未指定请求方法则将4个Restful方法均添加到 result 结果 + Set methods = entry.getKey().getMethodsCondition().getMethods(); + if (methods.isEmpty()) { + result.putAll(HttpMethod.GET, urls); + result.putAll(HttpMethod.POST, urls); + result.putAll(HttpMethod.PUT, urls); + result.putAll(HttpMethod.DELETE, urls); + } // 根据请求方法,添加到 result 结果 - entry.getKey().getMethodsCondition().getMethods().forEach(requestMethod -> { + methods.forEach(requestMethod -> { switch (requestMethod) { case GET: result.putAll(HttpMethod.GET, urls);