diff --git a/pig-auth/pom.xml b/pig-auth/pom.xml index b739a57b..93050217 100755 --- a/pig-auth/pom.xml +++ b/pig-auth/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 2.5.1 + 2.5.2.snapshot pig-auth @@ -39,13 +39,13 @@ com.pig4cloud pig-upms-api - 2.5.1 + 2.5.2.snapshot com.pig4cloud pig-common-security - 2.5.1 + 2.5.2.snapshot diff --git a/pig-common/pig-common-core/pom.xml b/pig-common/pig-common-core/pom.xml index ab65f408..c819bda6 100755 --- a/pig-common/pig-common-core/pom.xml +++ b/pig-common/pig-common-core/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 2.5.1 + 2.5.2.snapshot pig-common-core diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/FilterIgnorePropertiesConfig.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/FilterIgnorePropertiesConfig.java deleted file mode 100755 index 6a481094..00000000 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/FilterIgnorePropertiesConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com). - *

- * Licensed under the GNU Lesser General Public License 3.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * https://www.gnu.org/licenses/lgpl.html - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pig4cloud.pig.common.core.config; - -import lombok.Data; -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.context.annotation.Configuration; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author lengleng - * @date 2019/2/1 - * 放行参数配置 - */ -@Data -@Configuration -@RefreshScope -@ConditionalOnExpression("!'${ignore}'.isEmpty()") -@ConfigurationProperties(prefix = "ignore") -public class FilterIgnorePropertiesConfig { - /** - * 放行终端配置,网关不校验此处的终端 - */ - private List clients = new ArrayList<>(); - /** - * 放行url,放行的url不再被安全框架拦截 - */ - private List urls = new ArrayList<>(); - /** - * 不聚合swagger - */ - private List swaggerProviders = new ArrayList<>(); -} diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java index ea57d190..1dccf28e 100755 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java @@ -138,7 +138,7 @@ public class WebUtils extends org.springframework.web.util.WebUtils { * @param result 结果对象 */ public void renderJson(HttpServletResponse response, Object result) { - renderJson(response, result, MediaType.APPLICATION_JSON_UTF8_VALUE); + renderJson(response, result, MediaType.APPLICATION_JSON_VALUE); } /** @@ -158,44 +158,6 @@ public class WebUtils extends org.springframework.web.util.WebUtils { } } - /** - * 获取ip - * - * @return {String} - */ - public String getIP() { - return getIP(WebUtils.getRequest()); - } - - /** - * 获取ip - * - * @param request HttpServletRequest - * @return {String} - */ - public String getIP(HttpServletRequest request) { - Assert.notNull(request, "HttpServletRequest is null"); - String ip = request.getHeader("X-Requested-For"); - if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("X-Forwarded-For"); - } - if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("HTTP_CLIENT_IP"); - } - if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("HTTP_X_FORWARDED_FOR"); - } - if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getRemoteAddr(); - } - return StringUtils.isBlank(ip) ? null : ip.split(",")[0]; - } /** * 从request 获取CLIENT_ID diff --git a/pig-common/pig-common-core/src/main/resources/META-INF/spring.factories b/pig-common/pig-common-core/src/main/resources/META-INF/spring.factories index 1be0916e..05d43238 100755 --- a/pig-common/pig-common-core/src/main/resources/META-INF/spring.factories +++ b/pig-common/pig-common-core/src/main/resources/META-INF/spring.factories @@ -2,7 +2,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.pig4cloud.pig.common.core.config.JacksonConfig,\ com.pig4cloud.pig.common.core.config.RedisTemplateConfig,\ com.pig4cloud.pig.common.core.config.RestTemplateConfig,\ - com.pig4cloud.pig.common.core.config.FilterIgnorePropertiesConfig,\ com.pig4cloud.pig.common.core.exception.GlobalExceptionHandler,\ com.pig4cloud.pig.common.core.util.SpringContextHolder,\ com.pig4cloud.pig.common.core.mybatis.WebMvcConfig diff --git a/pig-common/pig-common-log/pom.xml b/pig-common/pig-common-log/pom.xml index 94f48e4a..55163fdd 100755 --- a/pig-common/pig-common-log/pom.xml +++ b/pig-common/pig-common-log/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 2.5.1 + 2.5.2.snapshot pig-common-log @@ -35,13 +35,13 @@ com.pig4cloud pig-common-core - 2.5.1 + 2.5.2.snapshot com.pig4cloud pig-upms-api - 2.5.1 + 2.5.2.snapshot diff --git a/pig-common/pig-common-security/pom.xml b/pig-common/pig-common-security/pom.xml index 890739bb..94798c92 100755 --- a/pig-common/pig-common-security/pom.xml +++ b/pig-common/pig-common-security/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 2.5.1 + 2.5.2.snapshot pig-common-security @@ -35,7 +35,7 @@ com.pig4cloud pig-common-core - 2.5.1 + 2.5.2.snapshot @@ -50,7 +50,7 @@ com.pig4cloud pig-upms-api - 2.5.1 + 2.5.2.snapshot diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PermitAllUrlConfiguration.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PermitAllUrlConfiguration.java new file mode 100755 index 00000000..d19e396f --- /dev/null +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PermitAllUrlConfiguration.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.security.component; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.cloud.context.config.annotation.RefreshScope; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author lengleng + * @date 2019-11-09 + *

+ * 放行接口配置 + */ +@Data +@RefreshScope +@ConfigurationProperties(prefix = "ignore") +public class PermitAllUrlConfiguration { + /** + * 放行url,支持 ant 表达式 + */ + private List urls = new ArrayList<>(); +} diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java index b9661ade..b37a94aa 100644 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java @@ -17,6 +17,7 @@ package com.pig4cloud.pig.common.security.component; import lombok.SneakyThrows; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -30,6 +31,7 @@ import org.springframework.web.client.RestTemplate; * @author lengleng * @date 2019/03/08 */ +@ConfigurationPropertiesScan @ComponentScan("com.pig4cloud.pig.common.security") public class PigResourceServerAutoConfiguration { @Bean diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerConfigurerAdapter.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerConfigurerAdapter.java index 8207d196..57707018 100644 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerConfigurerAdapter.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerConfigurerAdapter.java @@ -16,7 +16,6 @@ package com.pig4cloud.pig.common.security.component; -import com.pig4cloud.pig.common.core.config.FilterIgnorePropertiesConfig; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -45,10 +44,10 @@ public class PigResourceServerConfigurerAdapter extends ResourceServerConfigurer @Autowired protected RemoteTokenServices remoteTokenServices; @Autowired - private FilterIgnorePropertiesConfig ignorePropertiesConfig; - @Autowired private AccessDeniedHandler pigAccessDeniedHandler; @Autowired + private PermitAllUrlConfiguration permitAllUrl; + @Autowired private RestTemplate lbRestTemplate; /** @@ -64,7 +63,7 @@ public class PigResourceServerConfigurerAdapter extends ResourceServerConfigurer ExpressionUrlAuthorizationConfigurer .ExpressionInterceptUrlRegistry registry = httpSecurity .authorizeRequests(); - ignorePropertiesConfig.getUrls() + permitAllUrl.getUrls() .forEach(url -> registry.antMatchers(url).permitAll()); registry.anyRequest().authenticated() .and().csrf().disable(); diff --git a/pig-common/pom.xml b/pig-common/pom.xml index 203c1342..e144470b 100755 --- a/pig-common/pom.xml +++ b/pig-common/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 2.5.1 + 2.5.2.snapshot pig-common diff --git a/pig-config/pom.xml b/pig-config/pom.xml index b4e9d0ea..2b44479f 100755 --- a/pig-config/pom.xml +++ b/pig-config/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 2.5.1 + 2.5.2.snapshot pig-config diff --git a/pig-eureka/pom.xml b/pig-eureka/pom.xml index d510d03f..f1414d2d 100755 --- a/pig-eureka/pom.xml +++ b/pig-eureka/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 2.5.1 + 2.5.2.snapshot pig-eureka diff --git a/pig-gateway/pom.xml b/pig-gateway/pom.xml index 4dd3314c..3932e38f 100755 --- a/pig-gateway/pom.xml +++ b/pig-gateway/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 2.5.1 + 2.5.2.snapshot pig-gateway @@ -54,7 +54,7 @@ com.pig4cloud pig-common-core - 2.5.1 + 2.5.2.snapshot diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java index b3167554..83e6f956 100755 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java @@ -18,6 +18,7 @@ package com.pig4cloud.pig.gateway; import org.springframework.boot.SpringApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; import org.springframework.cloud.client.SpringCloudApplication; /** @@ -27,6 +28,7 @@ import org.springframework.cloud.client.SpringCloudApplication; * 网关应用 */ @SpringCloudApplication +@ConfigurationPropertiesScan public class PigGatewayApplication { public static void main(String[] args) { diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/IgnoreClientConfiguration.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/IgnoreClientConfiguration.java new file mode 100755 index 00000000..30b7060f --- /dev/null +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/IgnoreClientConfiguration.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.gateway.config; + +import lombok.Data; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Configuration; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author lengleng + * @date 2019/2/1 + * 放行参数配置 + */ +@Data +@RefreshScope +@ConfigurationProperties(prefix = "ignore") +public class IgnoreClientConfiguration { + /** + * 放行终端配置,网关不校验此处的终端 + */ + private List clients = new ArrayList<>(); +} diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java index eb06c092..f03c342a 100644 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java @@ -19,12 +19,12 @@ package com.pig4cloud.pig.gateway.filter; import cn.hutool.core.util.StrUtil; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.pig4cloud.pig.common.core.config.FilterIgnorePropertiesConfig; import com.pig4cloud.pig.common.core.constant.CommonConstants; import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.exception.ValidateCodeException; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.WebUtils; +import com.pig4cloud.pig.gateway.config.IgnoreClientConfiguration; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -46,9 +46,9 @@ import reactor.core.publisher.Mono; @Component @AllArgsConstructor public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory { + private final IgnoreClientConfiguration ignoreClient; private final ObjectMapper objectMapper; private final RedisTemplate redisTemplate; - private final FilterIgnorePropertiesConfig filterIgnorePropertiesConfig; @Override public GatewayFilter apply(Object config) { @@ -70,7 +70,7 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory { // 终端设置不校验, 直接向下执行 try { String[] clientInfos = WebUtils.getClientId(request); - if (filterIgnorePropertiesConfig.getClients().contains(clientInfos[0])) { + if (ignoreClient.getClients().contains(clientInfos[0])) { return chain.filter(exchange); } diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/handler/HystrixFallbackHandler.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/handler/HystrixFallbackHandler.java index ba3f4167..f18a144d 100755 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/handler/HystrixFallbackHandler.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/handler/HystrixFallbackHandler.java @@ -45,6 +45,6 @@ public class HystrixFallbackHandler implements HandlerFunction { originalUris.ifPresent(originalUri -> log.error("网关执行请求:{}失败,hystrix服务降级处理", originalUri)); return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value()) - .contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常")); + .contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("服务异常")); } } diff --git a/pig-upms/pig-upms-api/pom.xml b/pig-upms/pig-upms-api/pom.xml index 90563563..edbf0fca 100755 --- a/pig-upms/pig-upms-api/pom.xml +++ b/pig-upms/pig-upms-api/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-upms - 2.5.1 + 2.5.2.snapshot pig-upms-api @@ -35,7 +35,7 @@ com.pig4cloud pig-common-core - 2.5.1 + 2.5.2.snapshot diff --git a/pig-upms/pig-upms-biz/pom.xml b/pig-upms/pig-upms-biz/pom.xml index 0c10270c..3b09f375 100644 --- a/pig-upms/pig-upms-biz/pom.xml +++ b/pig-upms/pig-upms-biz/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-upms - 2.5.1 + 2.5.2.snapshot pig-upms-biz @@ -34,19 +34,19 @@ com.pig4cloud pig-upms-api - 2.5.1 + 2.5.2.snapshot com.pig4cloud pig-common-security - 2.5.1 + 2.5.2.snapshot com.pig4cloud pig-common-log - 2.5.1 + 2.5.2.snapshot diff --git a/pig-upms/pom.xml b/pig-upms/pom.xml index b7b61078..80564910 100755 --- a/pig-upms/pom.xml +++ b/pig-upms/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 2.5.1 + 2.5.2.snapshot pig-upms diff --git a/pig-visual/pig-codegen/pom.xml b/pig-visual/pig-codegen/pom.xml index 5ad14b01..bafec15e 100755 --- a/pig-visual/pig-codegen/pom.xml +++ b/pig-visual/pig-codegen/pom.xml @@ -22,7 +22,7 @@ com.pig4cloud pig-visual - 2.5.1 + 2.5.2.snapshot pig-codegen @@ -50,13 +50,13 @@ com.pig4cloud pig-common-core - 2.5.1 + 2.5.2.snapshot com.pig4cloud pig-common-security - 2.5.1 + 2.5.2.snapshot diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/SysGeneratorService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/SysGeneratorService.java index d70c5b81..aae54369 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/SysGeneratorService.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/SysGeneratorService.java @@ -39,6 +39,7 @@ public interface SysGeneratorService { /** * 分页查询表 * + * @param page 分页参数 * @param tableName 表名 * @return */ diff --git a/pig-visual/pig-monitor/pom.xml b/pig-visual/pig-monitor/pom.xml index cbb39147..ed33f763 100755 --- a/pig-visual/pig-monitor/pom.xml +++ b/pig-visual/pig-monitor/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-visual - 2.5.1 + 2.5.2.snapshot pig-monitor diff --git a/pig-visual/pom.xml b/pig-visual/pom.xml index b002115d..39643017 100755 --- a/pig-visual/pom.xml +++ b/pig-visual/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 2.5.1 + 2.5.2.snapshot pig-visual diff --git a/pom.xml b/pom.xml index 58d0b6f2..17396967 100755 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ com.pig4cloud pig - 2.5.1 + 2.5.2.snapshot ${project.artifactId} pom https://www.pig4cloud.com