From 69c49818fa31554f4a9d8e123ca1f0a154965726 Mon Sep 17 00:00:00 2001 From: lbw Date: Mon, 19 Dec 2022 18:54:41 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fixing=20a=20bug.=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4=E5=AF=B9?= =?UTF-8?q?=E5=A4=96=E6=9A=B4=E9=9C=B2=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/2pigxx.sql | 4 ++-- .../src/main/resources/application.yml | 2 +- .../security/component/PermitAllUrlProperties.java | 10 +++++----- .../security/component/PigBearerTokenExtractor.java | 2 +- .../component/PigResourceServerConfiguration.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/2pigxx.sql b/db/2pigxx.sql index 544307319..2d91bf4ac 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -893,7 +893,7 @@ CREATE TABLE `sys_tenant` ( -- Records of sys_tenant -- ---------------------------- BEGIN; -INSERT INTO `sys_tenant` VALUES (1, '北京分公司', '1', '', '2019-05-15 00:00:00', '2029-05-15 00:00:00', '0', '0', '', 'admin', '2019-05-15 15:44:57', '2022-12-09 15:27:50', 1601104338798153729); +INSERT INTO `sys_tenant` VALUES (1, '北京分公司', '1', '', '2019-05-15 00:00:00', '2029-05-15 00:00:00', '0', '0', '', 'admin', '2019-05-15 15:44:57', '2022-12-09 15:27:50', 1); COMMIT; -- ---------------------------- @@ -916,7 +916,7 @@ CREATE TABLE `sys_tenant_menu` ( -- ---------------------------- -- Records of sys_tenant_menu -- ---------------------------- -INSERT INTO `sys_tenant_menu` VALUES (1601104338798153729, '1231', '1000,1100,1101,1102,1103,1104,1200,1201,1202,1203,1300,1301,1302,1303,1304,1305,1400,1401,1402,1403,1404,1500,1501,1502,1503,1600,1601,1602,1603,1604,1605,1601095373834067969,1601095530717814785,1601095569972305921,1601095611131011073', '0', '0', 'admin', ' ', '2022-12-09 14:39:56', '2022-12-09 06:39:56'); +INSERT INTO `sys_tenant_menu` VALUES (1, '默认租户套餐', '1000,1100,1101,1102,1103,1104,1200,1201,1202,1203,1300,1301,1302,1303,1304,1305,1400,1401,1402,1403,1404,1500,1501,1502,1503,1600,1601,1602,1603,1604,1605,1601095373834067969,1601095530717814785,1601095569972305921,1601095611131011073', '0', '0', 'admin', ' ', '2022-12-09 14:39:56', '2022-12-09 06:39:56'); -- ---------------------------- -- Table structure for sys_user diff --git a/pigx-app-server/pigx-app-server-biz/src/main/resources/application.yml b/pigx-app-server/pigx-app-server-biz/src/main/resources/application.yml index 66d7e45c0..f7abeb654 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/resources/application.yml +++ b/pigx-app-server/pigx-app-server-biz/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 6060 + port: 7060 spring: application: diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PermitAllUrlProperties.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PermitAllUrlProperties.java index 76a9d8503..32b44a7be 100755 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PermitAllUrlProperties.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PermitAllUrlProperties.java @@ -39,7 +39,7 @@ import java.util.regex.Pattern; * 资源服务器对外直接暴露URL,如果设置contex-path 要特殊处理 */ @Slf4j -@ConfigurationProperties(prefix = "security.oauth2.ignore") +@ConfigurationProperties(prefix = "security.oauth2.client") public class PermitAllUrlProperties implements InitializingBean { private static final Pattern PATTERN = Pattern.compile("\\{(.*?)\\}"); @@ -48,11 +48,11 @@ public class PermitAllUrlProperties implements InitializingBean { @Getter @Setter - private List urls = new ArrayList<>(); + private List ignoreUrls = new ArrayList<>(); @Override public void afterPropertiesSet() { - urls.addAll(Arrays.asList(DEFAULT_IGNORE_URLS)); + ignoreUrls.addAll(Arrays.asList(DEFAULT_IGNORE_URLS)); RequestMappingHandlerMapping mapping = SpringContextHolder.getBean("requestMappingHandlerMapping"); Map map = mapping.getHandlerMethods(); @@ -62,12 +62,12 @@ public class PermitAllUrlProperties implements InitializingBean { // 获取方法上边的注解 替代path variable 为 * Inner method = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), Inner.class); Optional.ofNullable(method).ifPresent(inner -> Objects.requireNonNull(info.getPathPatternsCondition()) - .getPatternValues().forEach(url -> urls.add(ReUtil.replaceAll(url, PATTERN, "*")))); + .getPatternValues().forEach(url -> ignoreUrls.add(ReUtil.replaceAll(url, PATTERN, "*")))); // 获取类上边的注解, 替代path variable 为 * Inner controller = AnnotationUtils.findAnnotation(handlerMethod.getBeanType(), Inner.class); Optional.ofNullable(controller).ifPresent(inner -> Objects.requireNonNull(info.getPathPatternsCondition()) - .getPatternValues().forEach(url -> urls.add(ReUtil.replaceAll(url, PATTERN, "*")))); + .getPatternValues().forEach(url -> ignoreUrls.add(ReUtil.replaceAll(url, PATTERN, "*")))); }); } diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigBearerTokenExtractor.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigBearerTokenExtractor.java index aa4ea85a0..248f4029a 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigBearerTokenExtractor.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigBearerTokenExtractor.java @@ -55,7 +55,7 @@ public class PigBearerTokenExtractor implements BearerTokenResolver { @Override public String resolve(HttpServletRequest request) { - boolean match = urlProperties.getUrls().stream() + boolean match = urlProperties.getIgnoreUrls().stream() .anyMatch(url -> pathMatcher.match(url, request.getRequestURI())); if (match) { diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigResourceServerConfiguration.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigResourceServerConfiguration.java index 0f3d21a0d..f7964d344 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigResourceServerConfiguration.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigResourceServerConfiguration.java @@ -51,7 +51,7 @@ public class PigResourceServerConfiguration { SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http.authorizeHttpRequests(authorizeRequests -> authorizeRequests - .antMatchers(ArrayUtil.toArray(permitAllUrl.getUrls(), String.class)).permitAll().anyRequest() + .antMatchers(ArrayUtil.toArray(permitAllUrl.getIgnoreUrls(), String.class)).permitAll().anyRequest() .authenticated()) .oauth2ResourceServer( oauth2 -> oauth2.opaqueToken(token -> token.introspector(customOpaqueTokenIntrospector))