Commit 6d7491fb023ab1e8be6d6611c3c6d64a7e4ad30b
1 parent
6b3a54c8
!69fix(system): 修复更新账号时岗位为空时发生的空指针异常
Showing
1 changed file
with
11 additions
and
0 deletions
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java
| 1 | 1 | package cn.iocoder.yudao.framework.security.config; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.security.core.filter.TokenAuthenticationFilter; |
| 4 | 5 | import cn.iocoder.yudao.framework.web.config.WebProperties; |
| 5 | 6 | import com.google.common.collect.HashMultimap; |
| ... | ... | @@ -17,6 +18,7 @@ import org.springframework.security.web.AuthenticationEntryPoint; |
| 17 | 18 | import org.springframework.security.web.SecurityFilterChain; |
| 18 | 19 | import org.springframework.security.web.access.AccessDeniedHandler; |
| 19 | 20 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
| 21 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 20 | 22 | import org.springframework.web.method.HandlerMethod; |
| 21 | 23 | import org.springframework.web.servlet.mvc.method.RequestMappingInfo; |
| 22 | 24 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; |
| ... | ... | @@ -162,6 +164,15 @@ public class YudaoWebSecurityConfigurerAdapter { |
| 162 | 164 | continue; |
| 163 | 165 | } |
| 164 | 166 | Set<String> urls = entry.getKey().getPatternsCondition().getPatterns(); |
| 167 | + // 特殊:使用 @RequestMapping 注解,并且未写 method 属性,此时认为都需要免登录 | |
| 168 | + Set<RequestMethod> methods = entry.getKey().getMethodsCondition().getMethods(); | |
| 169 | + if (CollUtil.isEmpty(methods)) { // | |
| 170 | + result.putAll(HttpMethod.GET, urls); | |
| 171 | + result.putAll(HttpMethod.POST, urls); | |
| 172 | + result.putAll(HttpMethod.PUT, urls); | |
| 173 | + result.putAll(HttpMethod.DELETE, urls); | |
| 174 | + continue; | |
| 175 | + } | |
| 165 | 176 | // 根据请求方法,添加到 result 结果 |
| 166 | 177 | entry.getKey().getMethodsCondition().getMethods().forEach(requestMethod -> { |
| 167 | 178 | switch (requestMethod) { | ... | ... |