⬆️ up hutool 5.7 split 兼容性修改

This commit is contained in:
lbw committed 2021-06-25 10:35:16 +08:00
1 parent 9c81dc8c6e
commit 53a3951390
3 files changed
+15 -14

No files matched your search

@@ -172,18 +172,18 @@ public class PermitAllUrlResolver implements InitializingBean {
*/
public void registry(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
for (String url : getIgnoreUrls()) {
String[] strings = StrUtil.split(url, "|");
List<String> strings = StrUtil.split(url, "|");
// 仅配置对外暴露的URL ,则注册到 spring security的为全部方法
if (strings.length == 1) {
registry.antMatchers(strings[0]).permitAll();
if (strings.size() == 1) {
registry.antMatchers(strings.get(0)).permitAll();
continue;
}
// 当配置对外的URL|GET,POST 这种形式,则获取方法列表 并注册到 spring security
if (strings.length == 2) {
for (String method : StrUtil.split(strings[1], StrUtil.COMMA)) {
registry.antMatchers(HttpMethod.valueOf(method), strings[0]).permitAll();
if (strings.size() == 2) {
for (String method : StrUtil.split(strings.get(1), StrUtil.COMMA)) {
registry.antMatchers(HttpMethod.valueOf(method), strings.get(0)).permitAll();
}
continue;
}
@@ -18,7 +18,7 @@
package com.pig4cloud.pigx.common.security.component;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.Authentication;
@@ -28,6 +28,7 @@ import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 改造 {@link BearerTokenExtractor} 对公开权限的请求不进行校验
@@ -48,13 +49,13 @@ public class PigxBearerTokenExtractor extends BearerTokenExtractor {
// 2. 判断请求方法是否匹配
boolean result = permitAllUrlResolver.getIgnoreUrls().stream().anyMatch(url -> {
String[] strings = StrUtil.split(url, "|");
List<String> strings = StrUtil.split(url, "|");
// 1. 判断路径是否匹配
boolean match = pathMatcher.match(strings[0], request.getRequestURI());
boolean match = pathMatcher.match(strings.get(0), request.getRequestURI());
// 2. 判断方法是否匹配
if (strings.length == 2) {
String[] methods = StrUtil.split(strings[1], StrUtil.COMMA);
return ArrayUtil.contains(methods, request.getMethod()) && match;
if (strings.size() == 2) {
List<String> methods = StrUtil.split(strings.get(1), StrUtil.COMMA);
return CollUtil.contains(methods, request.getMethod()) && match;
}
return match;
});
+2 -2
View File
@@ -33,7 +33,7 @@
</organization>
<properties>
<spring-boot.version>2.5.1</spring-boot.version>
<spring-boot.version>2.5.2</spring-boot.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -43,7 +43,7 @@
<spring.checkstyle.version>0.0.28</spring.checkstyle.version>
<git.commit.version>2.2.5</git.commit.version>
<spring-boot-admin.version>2.4.1</spring-boot-admin.version>
<hutool.version>5.6.3</hutool.version>
<hutool.version>5.7.2</hutool.version>
<captcha.version>1.2.7</captcha.version>
<swagger.fox.version>3.0.0</swagger.fox.version>
<knife4j.version>3.0.2</knife4j.version>