mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-31 08:14:18 +08:00
refactor: 重构部分代码,修改过期类引用
Closes #I14NWH
This commit is contained in:
parent
d656146bfb
commit
fb60b8d000
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig</artifactId>
|
<artifactId>pig</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-auth</artifactId>
|
<artifactId>pig-auth</artifactId>
|
||||||
@ -39,13 +39,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-upms-api</artifactId>
|
<artifactId>pig-upms-api</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--security-->
|
<!--security-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-security</artifactId>
|
<artifactId>pig-common-security</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--JDBC相关-->
|
<!--JDBC相关-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common</artifactId>
|
<artifactId>pig-common</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-common-core</artifactId>
|
<artifactId>pig-common-core</artifactId>
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
|
|
||||||
* <p>
|
|
||||||
* 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
|
|
||||||
* <p>
|
|
||||||
* https://www.gnu.org/licenses/lgpl.html
|
|
||||||
* <p>
|
|
||||||
* 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<String> clients = new ArrayList<>();
|
|
||||||
/**
|
|
||||||
* 放行url,放行的url不再被安全框架拦截
|
|
||||||
*/
|
|
||||||
private List<String> urls = new ArrayList<>();
|
|
||||||
/**
|
|
||||||
* 不聚合swagger
|
|
||||||
*/
|
|
||||||
private List<String> swaggerProviders = new ArrayList<>();
|
|
||||||
}
|
|
@ -138,7 +138,7 @@ public class WebUtils extends org.springframework.web.util.WebUtils {
|
|||||||
* @param result 结果对象
|
* @param result 结果对象
|
||||||
*/
|
*/
|
||||||
public void renderJson(HttpServletResponse response, Object 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
|
* 从request 获取CLIENT_ID
|
||||||
|
@ -2,7 +2,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|||||||
com.pig4cloud.pig.common.core.config.JacksonConfig,\
|
com.pig4cloud.pig.common.core.config.JacksonConfig,\
|
||||||
com.pig4cloud.pig.common.core.config.RedisTemplateConfig,\
|
com.pig4cloud.pig.common.core.config.RedisTemplateConfig,\
|
||||||
com.pig4cloud.pig.common.core.config.RestTemplateConfig,\
|
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.exception.GlobalExceptionHandler,\
|
||||||
com.pig4cloud.pig.common.core.util.SpringContextHolder,\
|
com.pig4cloud.pig.common.core.util.SpringContextHolder,\
|
||||||
com.pig4cloud.pig.common.core.mybatis.WebMvcConfig
|
com.pig4cloud.pig.common.core.mybatis.WebMvcConfig
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common</artifactId>
|
<artifactId>pig-common</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-common-log</artifactId>
|
<artifactId>pig-common-log</artifactId>
|
||||||
@ -35,13 +35,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-core</artifactId>
|
<artifactId>pig-common-core</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--UPMS接口模块-->
|
<!--UPMS接口模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-upms-api</artifactId>
|
<artifactId>pig-upms-api</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--安全依赖获取上下文信息-->
|
<!--安全依赖获取上下文信息-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common</artifactId>
|
<artifactId>pig-common</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-common-security</artifactId>
|
<artifactId>pig-common-security</artifactId>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-core</artifactId>
|
<artifactId>pig-common-core</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--安全模块-->
|
<!--安全模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-upms-api</artifactId>
|
<artifactId>pig-upms-api</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -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
|
||||||
|
* <p>
|
||||||
|
* 放行接口配置
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@RefreshScope
|
||||||
|
@ConfigurationProperties(prefix = "ignore")
|
||||||
|
public class PermitAllUrlConfiguration {
|
||||||
|
/**
|
||||||
|
* 放行url,支持 ant 表达式
|
||||||
|
*/
|
||||||
|
private List<String> urls = new ArrayList<>();
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
package com.pig4cloud.pig.common.security.component;
|
package com.pig4cloud.pig.common.security.component;
|
||||||
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
@ -30,6 +31,7 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
* @author lengleng
|
* @author lengleng
|
||||||
* @date 2019/03/08
|
* @date 2019/03/08
|
||||||
*/
|
*/
|
||||||
|
@ConfigurationPropertiesScan
|
||||||
@ComponentScan("com.pig4cloud.pig.common.security")
|
@ComponentScan("com.pig4cloud.pig.common.security")
|
||||||
public class PigResourceServerAutoConfiguration {
|
public class PigResourceServerAutoConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.pig4cloud.pig.common.security.component;
|
package com.pig4cloud.pig.common.security.component;
|
||||||
|
|
||||||
import com.pig4cloud.pig.common.core.config.FilterIgnorePropertiesConfig;
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -45,10 +44,10 @@ public class PigResourceServerConfigurerAdapter extends ResourceServerConfigurer
|
|||||||
@Autowired
|
@Autowired
|
||||||
protected RemoteTokenServices remoteTokenServices;
|
protected RemoteTokenServices remoteTokenServices;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FilterIgnorePropertiesConfig ignorePropertiesConfig;
|
|
||||||
@Autowired
|
|
||||||
private AccessDeniedHandler pigAccessDeniedHandler;
|
private AccessDeniedHandler pigAccessDeniedHandler;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private PermitAllUrlConfiguration permitAllUrl;
|
||||||
|
@Autowired
|
||||||
private RestTemplate lbRestTemplate;
|
private RestTemplate lbRestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +63,7 @@ public class PigResourceServerConfigurerAdapter extends ResourceServerConfigurer
|
|||||||
ExpressionUrlAuthorizationConfigurer<HttpSecurity>
|
ExpressionUrlAuthorizationConfigurer<HttpSecurity>
|
||||||
.ExpressionInterceptUrlRegistry registry = httpSecurity
|
.ExpressionInterceptUrlRegistry registry = httpSecurity
|
||||||
.authorizeRequests();
|
.authorizeRequests();
|
||||||
ignorePropertiesConfig.getUrls()
|
permitAllUrl.getUrls()
|
||||||
.forEach(url -> registry.antMatchers(url).permitAll());
|
.forEach(url -> registry.antMatchers(url).permitAll());
|
||||||
registry.anyRequest().authenticated()
|
registry.anyRequest().authenticated()
|
||||||
.and().csrf().disable();
|
.and().csrf().disable();
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig</artifactId>
|
<artifactId>pig</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-common</artifactId>
|
<artifactId>pig-common</artifactId>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig</artifactId>
|
<artifactId>pig</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-config</artifactId>
|
<artifactId>pig-config</artifactId>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig</artifactId>
|
<artifactId>pig</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-eureka</artifactId>
|
<artifactId>pig-eureka</artifactId>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig</artifactId>
|
<artifactId>pig</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-gateway</artifactId>
|
<artifactId>pig-gateway</artifactId>
|
||||||
@ -54,7 +54,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-core</artifactId>
|
<artifactId>pig-common-core</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package com.pig4cloud.pig.gateway;
|
|||||||
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||||
import org.springframework.cloud.client.SpringCloudApplication;
|
import org.springframework.cloud.client.SpringCloudApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,6 +28,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
|
|||||||
* 网关应用
|
* 网关应用
|
||||||
*/
|
*/
|
||||||
@SpringCloudApplication
|
@SpringCloudApplication
|
||||||
|
@ConfigurationPropertiesScan
|
||||||
public class PigGatewayApplication {
|
public class PigGatewayApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -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<String> clients = new ArrayList<>();
|
||||||
|
}
|
@ -19,12 +19,12 @@ package com.pig4cloud.pig.gateway.filter;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
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.CommonConstants;
|
||||||
import com.pig4cloud.pig.common.core.constant.SecurityConstants;
|
import com.pig4cloud.pig.common.core.constant.SecurityConstants;
|
||||||
import com.pig4cloud.pig.common.core.exception.ValidateCodeException;
|
import com.pig4cloud.pig.common.core.exception.ValidateCodeException;
|
||||||
import com.pig4cloud.pig.common.core.util.R;
|
import com.pig4cloud.pig.common.core.util.R;
|
||||||
import com.pig4cloud.pig.common.core.util.WebUtils;
|
import com.pig4cloud.pig.common.core.util.WebUtils;
|
||||||
|
import com.pig4cloud.pig.gateway.config.IgnoreClientConfiguration;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -46,9 +46,9 @@ import reactor.core.publisher.Mono;
|
|||||||
@Component
|
@Component
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
|
public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
|
||||||
|
private final IgnoreClientConfiguration ignoreClient;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final RedisTemplate redisTemplate;
|
private final RedisTemplate redisTemplate;
|
||||||
private final FilterIgnorePropertiesConfig filterIgnorePropertiesConfig;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GatewayFilter apply(Object config) {
|
public GatewayFilter apply(Object config) {
|
||||||
@ -70,7 +70,7 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
|
|||||||
// 终端设置不校验, 直接向下执行
|
// 终端设置不校验, 直接向下执行
|
||||||
try {
|
try {
|
||||||
String[] clientInfos = WebUtils.getClientId(request);
|
String[] clientInfos = WebUtils.getClientId(request);
|
||||||
if (filterIgnorePropertiesConfig.getClients().contains(clientInfos[0])) {
|
if (ignoreClient.getClients().contains(clientInfos[0])) {
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,6 @@ public class HystrixFallbackHandler implements HandlerFunction<ServerResponse> {
|
|||||||
originalUris.ifPresent(originalUri -> log.error("网关执行请求:{}失败,hystrix服务降级处理", originalUri));
|
originalUris.ifPresent(originalUri -> log.error("网关执行请求:{}失败,hystrix服务降级处理", originalUri));
|
||||||
|
|
||||||
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
|
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
|
||||||
.contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常"));
|
.contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("服务异常"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-upms</artifactId>
|
<artifactId>pig-upms</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-upms-api</artifactId>
|
<artifactId>pig-upms-api</artifactId>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-core</artifactId>
|
<artifactId>pig-common-core</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-upms</artifactId>
|
<artifactId>pig-upms</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-upms-biz</artifactId>
|
<artifactId>pig-upms-biz</artifactId>
|
||||||
@ -34,19 +34,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-upms-api</artifactId>
|
<artifactId>pig-upms-api</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--安全模块-->
|
<!--安全模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-security</artifactId>
|
<artifactId>pig-common-security</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--日志处理-->
|
<!--日志处理-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-log</artifactId>
|
<artifactId>pig-common-log</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--配置中心客户端-->
|
<!--配置中心客户端-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig</artifactId>
|
<artifactId>pig</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-upms</artifactId>
|
<artifactId>pig-upms</artifactId>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-visual</artifactId>
|
<artifactId>pig-visual</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-codegen</artifactId>
|
<artifactId>pig-codegen</artifactId>
|
||||||
@ -50,13 +50,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-core</artifactId>
|
<artifactId>pig-common-core</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--安全模块-->
|
<!--安全模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-common-security</artifactId>
|
<artifactId>pig-common-security</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--代码生成模板引擎-->
|
<!--代码生成模板引擎-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -39,6 +39,7 @@ public interface SysGeneratorService {
|
|||||||
/**
|
/**
|
||||||
* 分页查询表
|
* 分页查询表
|
||||||
*
|
*
|
||||||
|
* @param page 分页参数
|
||||||
* @param tableName 表名
|
* @param tableName 表名
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig-visual</artifactId>
|
<artifactId>pig-visual</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-monitor</artifactId>
|
<artifactId>pig-monitor</artifactId>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig</artifactId>
|
<artifactId>pig</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>pig-visual</artifactId>
|
<artifactId>pig-visual</artifactId>
|
||||||
|
2
pom.xml
2
pom.xml
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
<groupId>com.pig4cloud</groupId>
|
<groupId>com.pig4cloud</groupId>
|
||||||
<artifactId>pig</artifactId>
|
<artifactId>pig</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.2.snapshot</version>
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<url>https://www.pig4cloud.com</url>
|
<url>https://www.pig4cloud.com</url>
|
||||||
|
Loading…
Reference in New Issue
Block a user