🔀 合并分支。合并pigx 更改的新特性
This commit is contained in:
commit
d31535f0f2
33 files changed
+137
-96
No files matched your search
+14
-2
@@ -40,11 +40,23 @@ spring:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: lengleng
|
||||
url: jdbc:mysql://mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
url: jdbc:pigx-mysql://mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
```
|
||||
|
||||
### 四、配置本地hosts
|
||||
|
||||
### 四、pigx-ui:
|
||||
从1.6.3开始,项目采用HOSTS配置ip的方式,所以开始运行项目前确保你的本机hosts文件中存在以下片段(以完全本机开发为例):
|
||||
|
||||
```
|
||||
# 本地测试环境
|
||||
127.0.0.1 pigx-mysql
|
||||
127.0.0.1 pigx-zookeeper
|
||||
127.0.0.1 pigx-redis
|
||||
127.0.0.1 pigx-gateway
|
||||
127.0.0.1 pigx-eureka
|
||||
```
|
||||
|
||||
### 五、pigx-ui:
|
||||
|
||||
```
|
||||
git clone https://www.gitee.wang/pig/pigx-ui.git
|
||||
|
||||
+6
-24
@@ -1,5 +1,11 @@
|
||||
version: '2'
|
||||
services:
|
||||
pigx-zookeeper:
|
||||
image: zookeeper:3.4.13
|
||||
ports:
|
||||
- 2181:2181
|
||||
restart: always
|
||||
|
||||
pigx-redis:
|
||||
image: redis:4.0.10
|
||||
ports:
|
||||
@@ -15,17 +21,12 @@ services:
|
||||
- 1025:1025
|
||||
|
||||
pigx-config:
|
||||
links:
|
||||
- pigx-eureka
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./pigx-config/Dockerfile
|
||||
restart: always
|
||||
|
||||
pigx-gateway:
|
||||
links:
|
||||
- pigx-eureka
|
||||
- pigx-redis
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./pigx-gateway/Dockerfile
|
||||
@@ -34,28 +35,18 @@ services:
|
||||
- 9999:9999
|
||||
|
||||
pigx-auth:
|
||||
links:
|
||||
- pigx-eureka
|
||||
- pigx-redis
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./pigx-auth/Dockerfile
|
||||
restart: always
|
||||
|
||||
pigx-upms:
|
||||
links:
|
||||
- pigx-eureka
|
||||
- pigx-redis
|
||||
- pigx-gateway
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./pigx-upms/pigx-upms-biz/Dockerfile
|
||||
restart: always
|
||||
|
||||
pigx-monitor:
|
||||
links:
|
||||
- pigx-eureka
|
||||
- pigx-redis
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./pigx-visual/pigx-monitor/Dockerfile
|
||||
@@ -64,9 +55,6 @@ services:
|
||||
- 5001:5001
|
||||
|
||||
pigx-daemon:
|
||||
links:
|
||||
- pigx-eureka
|
||||
- pigx-redis
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./pigx-visual/pigx-daemon/Dockerfile
|
||||
@@ -75,9 +63,6 @@ services:
|
||||
- 5002:5002
|
||||
|
||||
pigx-codegen:
|
||||
links:
|
||||
- pigx-eureka
|
||||
- pigx-redis
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./pigx-visual/pigx-codegen/Dockerfile
|
||||
@@ -93,9 +78,6 @@ services:
|
||||
restart: always
|
||||
|
||||
pigx-tx-manager:
|
||||
links:
|
||||
- pigx-eureka
|
||||
- pigx-redis
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./pigx-visual/pigx-tx-manager/Dockerfile
|
||||
|
||||
@@ -20,4 +20,4 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
defaultZone: http://pig:pig@pigx-eureka:1025/eureka/
|
||||
@@ -21,7 +21,7 @@
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/debug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
+55
-3
@@ -18,6 +18,8 @@
|
||||
package com.pig4cloud.pigx.common.security.component;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
@@ -25,10 +27,14 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Res
|
||||
import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
|
||||
import org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter;
|
||||
import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/6/22
|
||||
* <p>
|
||||
* 1. 支持remoteTokenServices 负载均衡
|
||||
* 2. 支持 获取用户全部信息
|
||||
*/
|
||||
public abstract class BaseResourceServerConfigurerAdapter extends ResourceServerConfigurerAdapter {
|
||||
@Autowired
|
||||
@@ -40,21 +46,49 @@ public abstract class BaseResourceServerConfigurerAdapter extends ResourceServer
|
||||
@Autowired
|
||||
protected UserDetailsService userDetailsService;
|
||||
|
||||
|
||||
/**
|
||||
* 默认的配置,对外暴露
|
||||
*
|
||||
* @param http
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public abstract void configure(HttpSecurity http) throws Exception;
|
||||
|
||||
/**
|
||||
* why add resourceId
|
||||
* https://stackoverflow.com/questions/28703847/how-do-you-set-a-resource-id-for-a-token
|
||||
* 提供子类重写
|
||||
* <p>
|
||||
* 1. 不重写,默认支持获取雍熙
|
||||
* 2. 重写notGetUser,提供性能
|
||||
* <p>
|
||||
* see codegen ResourceServerConfigurer
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
@Override
|
||||
public void configure(ResourceServerSecurityConfigurer resources) {
|
||||
canGetUser(resources);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@LoadBalanced
|
||||
public RestTemplate lbRestTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 不获取用户详细 只有用户名
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
protected void notGetUser(ResourceServerSecurityConfigurer resources) {
|
||||
DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();
|
||||
DefaultUserAuthenticationConverter userTokenConverter = new DefaultUserAuthenticationConverter();
|
||||
userTokenConverter.setUserDetailsService(userDetailsService);
|
||||
accessTokenConverter.setUserTokenConverter(userTokenConverter);
|
||||
|
||||
remoteTokenServices.setRestTemplate(lbRestTemplate());
|
||||
remoteTokenServices.setAccessTokenConverter(accessTokenConverter);
|
||||
resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
|
||||
.accessDeniedHandler(pigAccessDeniedHandler)
|
||||
@@ -62,4 +96,22 @@ public abstract class BaseResourceServerConfigurerAdapter extends ResourceServer
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上下文中获取用户全部信息,两次调用userDetailsService,影响性能
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
private void canGetUser(ResourceServerSecurityConfigurer resources) {
|
||||
DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();
|
||||
DefaultUserAuthenticationConverter userTokenConverter = new DefaultUserAuthenticationConverter();
|
||||
userTokenConverter.setUserDetailsService(userDetailsService);
|
||||
accessTokenConverter.setUserTokenConverter(userTokenConverter);
|
||||
|
||||
remoteTokenServices.setRestTemplate(lbRestTemplate());
|
||||
remoteTokenServices.setAccessTokenConverter(accessTokenConverter);
|
||||
resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
|
||||
.accessDeniedHandler(pigAccessDeniedHandler)
|
||||
.tokenServices(remoteTokenServices);
|
||||
}
|
||||
|
||||
}
|
||||
+4
-8
@@ -1,23 +1,19 @@
|
||||
package com.pig4cloud.pigx.common.security.component;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.*;
|
||||
import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration;
|
||||
import org.springframework.cloud.security.oauth2.client.AccessTokenContextRelay;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.oauth2.client.OAuth2ClientContext;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
|
||||
-1
@@ -21,7 +21,6 @@ package com.pig4cloud.pigx.common.security.feign;
|
||||
|
||||
import feign.RequestInterceptor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.security.oauth2.client.AccessTokenContextRelay;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
-1
@@ -24,7 +24,6 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.authentication.AuthenticationEventPublisher;
|
||||
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.DefaultAuthenticationEventPublisher;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
@@ -19,7 +19,7 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
defaultZone: http://pig:pig@pigx-eureka:1025/eureka/
|
||||
|
||||
# 暴露监控端点
|
||||
management:
|
||||
|
||||
@@ -6,7 +6,7 @@ jasypt:
|
||||
spring:
|
||||
redis:
|
||||
password:
|
||||
host: redis
|
||||
host: pigx-redis
|
||||
# Jackson配置
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
@@ -78,7 +78,7 @@ mybatis-plus:
|
||||
swagger:
|
||||
title: PigX Swagger API
|
||||
description: 全宇宙最牛逼的Spring Cloud微服务开发脚手架
|
||||
version: 1.6.2
|
||||
version: 1.7.0
|
||||
license: Powered By PigX
|
||||
licenseUrl: https://pig4cloud.com/
|
||||
terms-of-service-url: https://pig4cloud.com/
|
||||
@@ -93,12 +93,17 @@ swagger:
|
||||
- scope: server
|
||||
description: server all
|
||||
token-url-list:
|
||||
- ${security.auth.server}/token
|
||||
- http://pigx-gateway:9999/auth/oauth/token
|
||||
|
||||
## spring security 配置
|
||||
security:
|
||||
auth:
|
||||
server: http://lengleng:9999/auth/oauth
|
||||
oauth2:
|
||||
resource:
|
||||
token-info-uri: ${security.auth.server}/check_token
|
||||
loadBalanced: true
|
||||
token-info-uri: http://pigx-auth/oauth/check_token
|
||||
|
||||
# log配置
|
||||
logging:
|
||||
level:
|
||||
root: warn
|
||||
com.pig4cloud.pigx: info
|
||||
@@ -4,5 +4,5 @@ spring:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:mysql://mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
password: root
|
||||
url: jdbc:mysql://pigx-mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
@@ -12,7 +12,7 @@ spring:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:mysql://mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
password: root
|
||||
url: jdbc:mysql://pigx-mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
resources:
|
||||
static-locations: classpath:/static/,classpath:/views/
|
||||
@@ -13,12 +13,12 @@ spring:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:mysql://mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
password: root
|
||||
url: jdbc:mysql://pigx-mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
elasticjob:
|
||||
# 分布式任务协调依赖zookeeper
|
||||
zookeeper:
|
||||
server-lists: zookeeper:2181
|
||||
server-lists: pigx-zookeeper:2181
|
||||
namespace: pigx-daemon
|
||||
# 普通任务
|
||||
simples:
|
||||
|
||||
@@ -11,7 +11,7 @@ spring:
|
||||
- Path=/auth/**
|
||||
filters:
|
||||
# 验证码处理
|
||||
- ImageCodeGatewayFilter
|
||||
- ValidateCodeGatewayFilter
|
||||
# 前端密码解密
|
||||
- PasswordDecoderFilter
|
||||
#UPMS 模块
|
||||
|
||||
@@ -12,8 +12,8 @@ spring:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:mysql://mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
|
||||
password: root
|
||||
url: jdbc:mysql://pigx-mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
|
||||
|
||||
# swagger相关配置,覆盖全局配置
|
||||
swagger:
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/debug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
@@ -34,7 +34,7 @@
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/debug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class PasswordDecoderFilter extends AbstractGatewayFilterFactory {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
|
||||
// 不是登录请求,直接向下执行
|
||||
if (!StrUtil.containsAnyIgnoreCase(request.getURI().getPath(), ImageCodeGatewayFilter.OAUTH_TOKEN_URL)) {
|
||||
if (!StrUtil.containsAnyIgnoreCase(request.getURI().getPath(), ValidateCodeGatewayFilter.OAUTH_TOKEN_URL)) {
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
|
||||
+2
-9
@@ -18,7 +18,6 @@
|
||||
package com.pig4cloud.pigx.gateway.filter;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.gateway.config.SwaggerProvider;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -42,7 +41,8 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.a
|
||||
* <p>
|
||||
* 1. 对请求头中参数进行处理 from 参数进行清洗
|
||||
* 2. 重写StripPrefix = 1,支持全局
|
||||
* 3. 支持swagger添加X-Forwarded-Prefix header
|
||||
* <p>
|
||||
* 支持swagger添加X-Forwarded-Prefix header (F SR2 已经支持,不需要自己维护)
|
||||
*/
|
||||
@Component
|
||||
public class PigxRequestGlobalFilter implements GlobalFilter, Ordered {
|
||||
@@ -73,15 +73,8 @@ public class PigxRequestGlobalFilter implements GlobalFilter, Ordered {
|
||||
.build();
|
||||
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI());
|
||||
|
||||
// 3. 支持swagger添加X-Forwarded-Prefix header
|
||||
String path = request.getURI().getPath();
|
||||
if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) {
|
||||
return chain.filter(exchange.mutate().request(newRequest).build());
|
||||
}
|
||||
String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI));
|
||||
return chain.filter(exchange.mutate()
|
||||
.request(newRequest.mutate()
|
||||
.header(HEADER_NAME, basePath)
|
||||
.build()).build());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ import java.io.IOException;
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ImageCodeGatewayFilter extends AbstractGatewayFilterFactory {
|
||||
public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
|
||||
public static final String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY";
|
||||
public static final String OAUTH_TOKEN_URL = "/oauth/token";
|
||||
private static final String BASIC_ = "Basic ";
|
||||
+8
-1
@@ -27,6 +27,10 @@ import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/7/5
|
||||
@@ -37,7 +41,10 @@ import reactor.core.publisher.Mono;
|
||||
public class HystrixFallbackHandler implements HandlerFunction<ServerResponse> {
|
||||
@Override
|
||||
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
|
||||
log.error("网关执行请求:{}失败,hystrix服务降级处理", serverRequest.uri());
|
||||
Optional<Object> originalUris = serverRequest.attribute(GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
|
||||
|
||||
originalUris.ifPresent(originalUri -> log.error("网关执行请求:{}失败,hystrix服务降级处理", originalUri));
|
||||
|
||||
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
|
||||
.contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常"));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package com.pig4cloud.pigx.gateway.handler;
|
||||
|
||||
import com.google.code.kaptcha.Producer;
|
||||
import com.pig4cloud.pigx.gateway.filter.ImageCodeGatewayFilter;
|
||||
import com.pig4cloud.pigx.gateway.filter.ValidateCodeGatewayFilter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
@@ -58,7 +58,7 @@ public class ImageCodeHandler implements HandlerFunction<ServerResponse> {
|
||||
|
||||
//保存验证码信息
|
||||
String randomStr = serverRequest.queryParam("randomStr").get();
|
||||
redisTemplate.opsForValue().set(ImageCodeGatewayFilter.DEFAULT_CODE_KEY + randomStr, text, 60, TimeUnit.SECONDS);
|
||||
redisTemplate.opsForValue().set(ValidateCodeGatewayFilter.DEFAULT_CODE_KEY + randomStr, text, 60, TimeUnit.SECONDS);
|
||||
|
||||
// 转换流信息写出
|
||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
||||
|
||||
@@ -22,6 +22,6 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
defaultZone: http://pig:pig@pigx-eureka:1025/eureka/
|
||||
|
||||
|
||||
-1
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
||||
|
||||
@@ -16,9 +16,6 @@ spring:
|
||||
discovery:
|
||||
enabled: true
|
||||
service-id: pigx-config
|
||||
datasource:
|
||||
url:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
|
||||
# 注册中心配置
|
||||
eureka:
|
||||
@@ -26,4 +23,4 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
defaultZone: http://pig:pig@pigx-eureka:1025/eureka/
|
||||
+2
-3
@@ -44,13 +44,12 @@ public class ResourceServerConfigurer extends BaseResourceServerConfigurerAdapte
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写抽象类实现,不需要调用feign 获取 userdetils
|
||||
* 重写抽象类实现,不需要调用feign 获取 userDetailsService
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
@Override
|
||||
public void configure(ResourceServerSecurityConfigurer resources) {
|
||||
resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
|
||||
.accessDeniedHandler(pigAccessDeniedHandler);
|
||||
notGetUser(resources);
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,7 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
defaultZone: http://pig:pig@pigx-eureka:1025/eureka/
|
||||
logging:
|
||||
level:
|
||||
root: info
|
||||
@@ -1,7 +1,5 @@
|
||||
package ${package}.${moduleName}.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
@@ -10,6 +8,7 @@ import com.pig4cloud.pigx.common.core.util.Query;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+1
-2
@@ -50,7 +50,6 @@ public class ResourceServerConfigurer extends BaseResourceServerConfigurerAdapte
|
||||
*/
|
||||
@Override
|
||||
public void configure(ResourceServerSecurityConfigurer resources) {
|
||||
resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
|
||||
.accessDeniedHandler(pigAccessDeniedHandler);
|
||||
notGetUser(resources);
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,4 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
defaultZone: http://pig:pig@pigx-eureka:1025/eureka/
|
||||
@@ -20,4 +20,4 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
defaultZone: http://pig:pig@pigx-eureka:1025/eureka/
|
||||
@@ -20,5 +20,5 @@ eureka:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
defaultZone: http://pig:pig@pigx-eureka:1025/eureka/
|
||||
|
||||
@@ -30,14 +30,14 @@
|
||||
<url>https://www.pig4cloud.com</url>
|
||||
|
||||
<properties>
|
||||
<pigx.version>1.6.3</pigx.version>
|
||||
<spring-boot.version>2.0.4.RELEASE</spring-boot.version>
|
||||
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
|
||||
<pigx.version>1.7.0</pigx.version>
|
||||
<spring-boot.version>2.0.6.RELEASE</spring-boot.version>
|
||||
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
|
||||
<spring-platform.version>Cairo-SR3</spring-platform.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<monitor.version>2.0.3</monitor.version>
|
||||
<monitor.version>2.0.4</monitor.version>
|
||||
<hutool.version>4.1.13</hutool.version>
|
||||
<mbp.boot.version>2.3</mbp.boot.version>
|
||||
<kaptcha.version>0.0.9</kaptcha.version>
|
||||
|
||||
Reference in new issue
Block a user