From 7ba0443f601c60c6b56fdd0e142804d14a85867b Mon Sep 17 00:00:00 2001 From: smallchill Date: Thu, 7 Jul 2022 23:49:00 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=203.0.0.RELEASE=20=E5=8D=87=E7=BA=A7=20S?= =?UTF-8?q?pringCloud=202021,=20SpringBoot=202.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blade-biz-common/pom.xml | 4 +- .../config/BladeCommonConfiguration.java | 2 +- .../blade-dubbo-provider-api/pom.xml | 2 +- blade-example-api/blade-stream-api/pom.xml | 2 +- blade-example-api/pom.xml | 4 +- blade-example/blade-dubbo-consumer/pom.xml | 2 +- .../consumer/DubboConsumerApplication.java | 6 +-- .../config/ConsumerConfiguration.java | 2 +- blade-example/blade-dubbo-provider/pom.xml | 2 +- .../provider/DubboProviderApplication.java | 6 +-- blade-example/blade-easypoi/pom.xml | 2 +- .../example/poi/test/web/cfg/Cfg.java | 2 +- blade-example/blade-mq-kafka/pom.xml | 2 +- .../mq/kafka/config/KafkaConfiguration.java | 2 +- blade-example/blade-mq-rabbit/pom.xml | 2 +- .../rabbit/config/RabbitMqConfiguration.java | 2 +- blade-example/blade-seata-order/pom.xml | 2 +- blade-example/blade-seata-storage/pom.xml | 2 +- blade-example/blade-stream-consumer/pom.xml | 2 +- blade-example/blade-stream-provider/pom.xml | 2 +- blade-example/blade-websocket/pom.xml | 2 +- .../websocket/config/WebSocketConfig.java | 2 +- blade-example/pom.xml | 4 +- blade-gateway/pom.xml | 54 ++++--------------- .../gateway/GateWayApplication.java | 10 ++-- .../config/ErrorHandlerConfiguration.java | 5 +- .../config/RouterFunctionConfiguration.java | 4 +- .../gateway/filter/AuthFilter.java | 11 ++-- .../filter/GlobalRequestLogFilter.java | 8 +-- .../filter/GlobalResponseLogFilter.java | 6 +-- .../gateway/props/AuthProperties.java | 18 +++++++ .../gateway/provider/AuthProvider.java | 12 ++--- .../gateway/provider/AuthSecure.java | 37 +++++++++++++ .../gateway/provider/BasicSecure.java | 37 +++++++++++++ .../gateway/provider/SignSecure.java | 37 +++++++++++++ .../src/main/resources/application-dev.yml | 17 +++--- .../src/main/resources/bootstrap.yml | 11 ---- blade-service-api/blade-demo-api/pom.xml | 2 +- blade-service-api/pom.xml | 4 +- blade-service/blade-demo/pom.xml | 2 +- .../com/example/demo/DemoApplication.java | 4 +- .../demo/config/DemoConfiguration.java | 2 +- .../src/test/java/BladeDemoTest.java | 8 +-- blade-service/pom.xml | 4 +- doc/nacos/blade.yaml | 29 +--------- pom.xml | 8 +-- script/docker/app/.env | 2 +- 47 files changed, 225 insertions(+), 167 deletions(-) create mode 100644 blade-gateway/src/main/java/org/springblade/gateway/provider/AuthSecure.java create mode 100644 blade-gateway/src/main/java/org/springblade/gateway/provider/BasicSecure.java create mode 100644 blade-gateway/src/main/java/org/springblade/gateway/provider/SignSecure.java diff --git a/blade-biz-common/pom.xml b/blade-biz-common/pom.xml index 08d95262a..90d25c8bf 100644 --- a/blade-biz-common/pom.xml +++ b/blade-biz-common/pom.xml @@ -5,7 +5,7 @@ BladeX-Biz org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 @@ -21,7 +21,7 @@ org.springblade - blade-starter-ribbon + blade-starter-loadbalancer org.springblade diff --git a/blade-biz-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java b/blade-biz-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java index c4e4dd051..f6943e85f 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java +++ b/blade-biz-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java @@ -25,7 +25,7 @@ import org.springframework.context.annotation.Configuration; * * @author Chill */ -@Configuration +@Configuration(proxyBeanMethods = false) @AllArgsConstructor public class BladeCommonConfiguration { diff --git a/blade-example-api/blade-dubbo-provider-api/pom.xml b/blade-example-api/blade-dubbo-provider-api/pom.xml index 1b822c84b..d6b56c533 100644 --- a/blade-example-api/blade-dubbo-provider-api/pom.xml +++ b/blade-example-api/blade-dubbo-provider-api/pom.xml @@ -5,7 +5,7 @@ blade-example-api org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example-api/blade-stream-api/pom.xml b/blade-example-api/blade-stream-api/pom.xml index 08bec1c23..0735bda5a 100644 --- a/blade-example-api/blade-stream-api/pom.xml +++ b/blade-example-api/blade-stream-api/pom.xml @@ -5,7 +5,7 @@ blade-example-api org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example-api/pom.xml b/blade-example-api/pom.xml index f9e3ae190..6eefd703b 100644 --- a/blade-example-api/pom.xml +++ b/blade-example-api/pom.xml @@ -5,13 +5,13 @@ BladeX-Biz org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 blade-example-api ${project.artifactId} - 2.9.1.RELEASE + 3.0.0.RELEASE pom BladeX 微服务范例API集合 diff --git a/blade-example/blade-dubbo-consumer/pom.xml b/blade-example/blade-dubbo-consumer/pom.xml index c6ecd167b..c64643c43 100644 --- a/blade-example/blade-dubbo-consumer/pom.xml +++ b/blade-example/blade-dubbo-consumer/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/DubboConsumerApplication.java b/blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/DubboConsumerApplication.java index cca653f66..ebf9936d0 100644 --- a/blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/DubboConsumerApplication.java +++ b/blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/DubboConsumerApplication.java @@ -18,9 +18,8 @@ package org.springblade.example.consumer; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.springblade.common.constant.LauncherConstant; -import org.springblade.core.cloud.feign.EnableBladeFeign; +import org.springblade.core.cloud.client.BladeCloudApplication; import org.springblade.core.launch.BladeApplication; -import org.springframework.cloud.client.SpringCloudApplication; /** * DubboConsumerApplication @@ -28,8 +27,7 @@ import org.springframework.cloud.client.SpringCloudApplication; * @author Chill */ @EnableDubbo -@EnableBladeFeign -@SpringCloudApplication +@BladeCloudApplication public class DubboConsumerApplication { public static void main(String[] args) { diff --git a/blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/config/ConsumerConfiguration.java b/blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/config/ConsumerConfiguration.java index c12d99725..4a73938d6 100644 --- a/blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/config/ConsumerConfiguration.java +++ b/blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/config/ConsumerConfiguration.java @@ -25,7 +25,7 @@ import org.springframework.context.annotation.Configuration; * * @author Chill */ -@Configuration +@Configuration(proxyBeanMethods = false) public class ConsumerConfiguration { @Bean diff --git a/blade-example/blade-dubbo-provider/pom.xml b/blade-example/blade-dubbo-provider/pom.xml index aa10fd644..4a65f9e29 100644 --- a/blade-example/blade-dubbo-provider/pom.xml +++ b/blade-example/blade-dubbo-provider/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-dubbo-provider/src/main/java/org/springblade/example/provider/DubboProviderApplication.java b/blade-example/blade-dubbo-provider/src/main/java/org/springblade/example/provider/DubboProviderApplication.java index c2c808854..cd0e073fb 100644 --- a/blade-example/blade-dubbo-provider/src/main/java/org/springblade/example/provider/DubboProviderApplication.java +++ b/blade-example/blade-dubbo-provider/src/main/java/org/springblade/example/provider/DubboProviderApplication.java @@ -2,9 +2,8 @@ package org.springblade.example.provider; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.springblade.common.constant.LauncherConstant; -import org.springblade.core.cloud.feign.EnableBladeFeign; +import org.springblade.core.cloud.client.BladeCloudApplication; import org.springblade.core.launch.BladeApplication; -import org.springframework.cloud.client.SpringCloudApplication; /** * DubboProviderApplication @@ -12,8 +11,7 @@ import org.springframework.cloud.client.SpringCloudApplication; * @author Chill */ @EnableDubbo -@EnableBladeFeign -@SpringCloudApplication +@BladeCloudApplication public class DubboProviderApplication { public static void main(String[] args) { diff --git a/blade-example/blade-easypoi/pom.xml b/blade-example/blade-easypoi/pom.xml index 80fa3ba36..585e8fb41 100644 --- a/blade-example/blade-easypoi/pom.xml +++ b/blade-example/blade-easypoi/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-easypoi/src/main/java/org/springblade/example/poi/test/web/cfg/Cfg.java b/blade-example/blade-easypoi/src/main/java/org/springblade/example/poi/test/web/cfg/Cfg.java index e924858f7..c91129b7f 100644 --- a/blade-example/blade-easypoi/src/main/java/org/springblade/example/poi/test/web/cfg/Cfg.java +++ b/blade-example/blade-easypoi/src/main/java/org/springblade/example/poi/test/web/cfg/Cfg.java @@ -4,7 +4,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.view.BeanNameViewResolver; -@Configuration +@Configuration(proxyBeanMethods = false) public class Cfg { @Bean diff --git a/blade-example/blade-mq-kafka/pom.xml b/blade-example/blade-mq-kafka/pom.xml index 9e8517dca..d50848ce0 100644 --- a/blade-example/blade-mq-kafka/pom.xml +++ b/blade-example/blade-mq-kafka/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-mq-kafka/src/main/java/org/springblade/example/mq/kafka/config/KafkaConfiguration.java b/blade-example/blade-mq-kafka/src/main/java/org/springblade/example/mq/kafka/config/KafkaConfiguration.java index d98416993..0b2767627 100644 --- a/blade-example/blade-mq-kafka/src/main/java/org/springblade/example/mq/kafka/config/KafkaConfiguration.java +++ b/blade-example/blade-mq-kafka/src/main/java/org/springblade/example/mq/kafka/config/KafkaConfiguration.java @@ -16,7 +16,7 @@ import org.springframework.kafka.listener.ContainerProperties; * * @author yangkai.shen */ -@Configuration +@Configuration(proxyBeanMethods = false) @EnableConfigurationProperties({KafkaProperties.class}) @EnableKafka @AllArgsConstructor diff --git a/blade-example/blade-mq-rabbit/pom.xml b/blade-example/blade-mq-rabbit/pom.xml index 0c0e8e5ad..50207b6bd 100644 --- a/blade-example/blade-mq-rabbit/pom.xml +++ b/blade-example/blade-mq-rabbit/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-mq-rabbit/src/main/java/org/springblade/example/mq/rabbit/config/RabbitMqConfiguration.java b/blade-example/blade-mq-rabbit/src/main/java/org/springblade/example/mq/rabbit/config/RabbitMqConfiguration.java index 874dc01ce..a89fb08a0 100644 --- a/blade-example/blade-mq-rabbit/src/main/java/org/springblade/example/mq/rabbit/config/RabbitMqConfiguration.java +++ b/blade-example/blade-mq-rabbit/src/main/java/org/springblade/example/mq/rabbit/config/RabbitMqConfiguration.java @@ -17,7 +17,7 @@ import java.util.Map; * @author yangkai.shen */ @Slf4j -@Configuration +@Configuration(proxyBeanMethods = false) public class RabbitMqConfiguration { @Bean diff --git a/blade-example/blade-seata-order/pom.xml b/blade-example/blade-seata-order/pom.xml index 2cd93988e..89c4bf70a 100644 --- a/blade-example/blade-seata-order/pom.xml +++ b/blade-example/blade-seata-order/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-seata-storage/pom.xml b/blade-example/blade-seata-storage/pom.xml index de44e5922..11d7bb22c 100644 --- a/blade-example/blade-seata-storage/pom.xml +++ b/blade-example/blade-seata-storage/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-stream-consumer/pom.xml b/blade-example/blade-stream-consumer/pom.xml index 7a759bc08..223e639af 100644 --- a/blade-example/blade-stream-consumer/pom.xml +++ b/blade-example/blade-stream-consumer/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-stream-provider/pom.xml b/blade-example/blade-stream-provider/pom.xml index 80b54c263..04a779baf 100644 --- a/blade-example/blade-stream-provider/pom.xml +++ b/blade-example/blade-stream-provider/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-websocket/pom.xml b/blade-example/blade-websocket/pom.xml index d1928bef1..761718503 100644 --- a/blade-example/blade-websocket/pom.xml +++ b/blade-example/blade-websocket/pom.xml @@ -5,7 +5,7 @@ blade-example org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-example/blade-websocket/src/main/java/org/springblade/websocket/config/WebSocketConfig.java b/blade-example/blade-websocket/src/main/java/org/springblade/websocket/config/WebSocketConfig.java index d5759413a..c098a069d 100644 --- a/blade-example/blade-websocket/src/main/java/org/springblade/websocket/config/WebSocketConfig.java +++ b/blade-example/blade-websocket/src/main/java/org/springblade/websocket/config/WebSocketConfig.java @@ -11,7 +11,7 @@ import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerCo * * @author rajeevkumarsingh */ -@Configuration +@Configuration(proxyBeanMethods = false) @EnableWebSocketMessageBroker public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { diff --git a/blade-example/pom.xml b/blade-example/pom.xml index 7446ad197..6ace0b9f2 100644 --- a/blade-example/pom.xml +++ b/blade-example/pom.xml @@ -5,13 +5,13 @@ BladeX-Biz org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 blade-example ${project.artifactId} - 2.9.1.RELEASE + 3.0.0.RELEASE pom BladeX 微服务范例集合 diff --git a/blade-gateway/pom.xml b/blade-gateway/pom.xml index de7c5ecfd..6718eac13 100644 --- a/blade-gateway/pom.xml +++ b/blade-gateway/pom.xml @@ -5,7 +5,7 @@ BladeX-Biz org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 @@ -40,6 +40,10 @@ + + org.springblade + blade-starter-metrics + org.springblade blade-starter-jwt @@ -53,58 +57,22 @@ org.springframework.cloud spring-cloud-starter-gateway - - org.springframework.boot - spring-boot-starter-data-redis-reactive - - - de.codecentric - spring-boot-admin-starter-client - - org.springframework.cloud - spring-cloud-starter-netflix-hystrix - - - commons-logging - commons-logging - - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery + spring-cloud-starter-bootstrap com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - io.springfox - springfox-swagger2 - - - io.swagger - swagger-models - - + spring-cloud-starter-alibaba-sentinel - io.swagger - swagger-models + org.springframework.boot + spring-boot-starter-data-redis-reactive - com.github.xiaoymin - knife4j-spring-ui + de.codecentric + spring-boot-admin-starter-client - diff --git a/blade-gateway/src/main/java/org/springblade/gateway/GateWayApplication.java b/blade-gateway/src/main/java/org/springblade/gateway/GateWayApplication.java index ee72a853a..de1c9485c 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/GateWayApplication.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/GateWayApplication.java @@ -16,10 +16,10 @@ */ package org.springblade.gateway; -import org.springblade.core.launch.constant.AppConstant; import org.springblade.core.launch.BladeApplication; -import org.springframework.cloud.client.SpringCloudApplication; -import org.springframework.cloud.netflix.hystrix.EnableHystrix; +import org.springblade.core.launch.constant.AppConstant; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.scheduling.annotation.EnableScheduling; /** @@ -27,9 +27,9 @@ import org.springframework.scheduling.annotation.EnableScheduling; * * @author Chill */ -@EnableHystrix @EnableScheduling -@SpringCloudApplication +@EnableDiscoveryClient +@SpringBootApplication public class GateWayApplication { public static void main(String[] args) { diff --git a/blade-gateway/src/main/java/org/springblade/gateway/config/ErrorHandlerConfiguration.java b/blade-gateway/src/main/java/org/springblade/gateway/config/ErrorHandlerConfiguration.java index eae509514..06329ba68 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/config/ErrorHandlerConfiguration.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/config/ErrorHandlerConfiguration.java @@ -20,7 +20,6 @@ package org.springblade.gateway.config; import com.fasterxml.jackson.databind.ObjectMapper; import org.springblade.gateway.handler.ErrorExceptionHandler; import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.web.ResourceProperties; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -32,9 +31,9 @@ import org.springframework.context.annotation.Configuration; * * @author Chill */ -@Configuration +@Configuration(proxyBeanMethods = false) @AutoConfigureBefore(ErrorWebFluxAutoConfiguration.class) -@EnableConfigurationProperties({ServerProperties.class, ResourceProperties.class}) +@EnableConfigurationProperties({ServerProperties.class}) public class ErrorHandlerConfiguration { @Bean diff --git a/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java b/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java index 1e4e2656c..db4814ba5 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java @@ -39,7 +39,7 @@ import reactor.core.publisher.Mono; * @author Chill */ @Slf4j -@Configuration +@Configuration(proxyBeanMethods = false) @AllArgsConstructor @EnableConfigurationProperties({AuthProperties.class}) public class RouterFunctionConfiguration { @@ -47,7 +47,7 @@ public class RouterFunctionConfiguration { /** * 这里为支持的请求头,如果有自定义的header字段请自己添加 */ - private static final String ALLOWED_HEADERS = "X-Requested-With, Tenant-Id, Blade-Auth, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, client"; + private static final String ALLOWED_HEADERS = "X-Requested-With, Tenant-Id, Blade-Auth, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, client, knfie4j-gateway-request, knife4j-gateway-code, request-origion"; private static final String ALLOWED_METHODS = "GET,POST,PUT,DELETE,OPTIONS,HEAD"; private static final String ALLOWED_ORIGIN = "*"; private static final String ALLOWED_EXPOSE = "*"; diff --git a/blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java b/blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java index aa0c86742..4175149f1 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java @@ -16,12 +16,12 @@ */ package org.springblade.gateway.filter; +import com.alibaba.nacos.common.utils.StringUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.jsonwebtoken.Claims; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; import org.springblade.core.jwt.JwtUtil; import org.springblade.core.jwt.props.JwtProperties; import org.springblade.core.launch.constant.TokenConstant; @@ -36,6 +36,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.http.HttpStatus; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.stereotype.Component; +import org.springframework.util.AntPathMatcher; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -54,6 +55,7 @@ public class AuthFilter implements GlobalFilter, Ordered { private final AuthProperties authProperties; private final ObjectMapper objectMapper; private final JwtProperties jwtProperties; + private final AntPathMatcher antPathMatcher = new AntPathMatcher(); @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { @@ -89,8 +91,11 @@ public class AuthFilter implements GlobalFilter, Ordered { } private boolean isSkip(String path) { - return AuthProvider.getDefaultSkipUrl().stream().map(url -> url.replace(AuthProvider.TARGET, AuthProvider.REPLACEMENT)).anyMatch(path::startsWith) - || authProperties.getSkipUrl().stream().map(url -> url.replace(AuthProvider.TARGET, AuthProvider.REPLACEMENT)).anyMatch(path::startsWith); + return AuthProvider.getDefaultSkipUrl().stream().anyMatch(pattern -> antPathMatcher.match(pattern, path)) + || authProperties.getSkipUrl().stream().anyMatch(pattern -> antPathMatcher.match(pattern, path)) + || authProperties.getAuth().stream().anyMatch(auth -> antPathMatcher.match(auth.getPattern(), path)) + || authProperties.getBasic().stream().anyMatch(basic -> antPathMatcher.match(basic.getPattern(), path)) + || authProperties.getSign().stream().anyMatch(sign -> antPathMatcher.match(sign.getPattern(), path)); } private Mono unAuth(ServerHttpResponse resp, String msg) { diff --git a/blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalRequestLogFilter.java b/blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalRequestLogFilter.java index b4a9cce84..a81b2d0f6 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalRequestLogFilter.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalRequestLogFilter.java @@ -16,10 +16,10 @@ */ package org.springblade.gateway.filter; +import com.alibaba.nacos.common.utils.StringUtils; import io.jsonwebtoken.Claims; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; import org.springblade.core.jwt.JwtUtil; import org.springblade.gateway.provider.AuthProvider; import org.springblade.gateway.provider.RequestProvider; @@ -49,7 +49,7 @@ import java.util.List; * @author dream.lu */ @Slf4j -@Configuration +@Configuration(proxyBeanMethods = false) @RequiredArgsConstructor @ConditionalOnProperty(value = "blade.log.request.enabled", havingValue = "true", matchIfMissing = true) public class GlobalRequestLogFilter implements GlobalFilter, Ordered { @@ -93,9 +93,9 @@ public class GlobalRequestLogFilter implements GlobalFilter, Ordered { beforeReqArgs.add((claims == null) ? "" : claims.toString()); beforeReqLog.append("===Headers=== {}: {}\n"); beforeReqArgs.add(headerName.concat("-original")); - beforeReqArgs.add(StringUtils.join(headerValue.toArray())); + beforeReqArgs.add(headerValue.toArray()); } else { - beforeReqArgs.add(StringUtils.join(headerValue.toArray())); + beforeReqArgs.add(headerValue.toArray()); } }); diff --git a/blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalResponseLogFilter.java b/blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalResponseLogFilter.java index 9d238d58e..355b8a715 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalResponseLogFilter.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalResponseLogFilter.java @@ -16,9 +16,9 @@ */ package org.springblade.gateway.filter; +import com.alibaba.nacos.common.utils.StringUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.gateway.filter.GatewayFilterChain; @@ -42,7 +42,7 @@ import java.util.List; * @author dream.lu */ @Slf4j -@Configuration +@Configuration(proxyBeanMethods = false) @RequiredArgsConstructor @ConditionalOnProperty(value = "blade.log.request.enabled", havingValue = "true", matchIfMissing = true) public class GlobalResponseLogFilter implements GlobalFilter, Ordered { @@ -82,7 +82,7 @@ public class GlobalResponseLogFilter implements GlobalFilter, Ordered { headers.forEach((headerName, headerValue) -> { responseLog.append("===Headers=== {}: {}\n"); responseArgs.add(headerName); - responseArgs.add(StringUtils.join(headerValue.toArray())); + responseArgs.add(headerValue.toArray()); }); responseLog.append("================ Gateway Response End =================\n"); diff --git a/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java b/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java index efb8d54d4..d76eb7dda 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java @@ -17,6 +17,9 @@ package org.springblade.gateway.props; import lombok.Data; +import org.springblade.gateway.provider.AuthSecure; +import org.springblade.gateway.provider.BasicSecure; +import org.springblade.gateway.provider.SignSecure; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.cloud.context.config.annotation.RefreshScope; @@ -38,4 +41,19 @@ public class AuthProperties { */ private final List skipUrl = new ArrayList<>(); + /** + * 自定义授权配置 + */ + private final List auth = new ArrayList<>(); + + /** + * 基础认证配置 + */ + private final List basic = new ArrayList<>(); + + /** + * 签名认证配置 + */ + private final List sign = new ArrayList<>(); + } diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java index 44485372c..260db6cee 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java @@ -28,8 +28,6 @@ import java.util.List; */ public class AuthProvider { - public static final String TARGET = "/**"; - public static final String REPLACEMENT = ""; public static final String AUTH_KEY = TokenConstant.HEADER; private static final List DEFAULT_SKIP_URL = new ArrayList<>(); @@ -39,12 +37,12 @@ public class AuthProvider { DEFAULT_SKIP_URL.add("/oauth/captcha/**"); DEFAULT_SKIP_URL.add("/oauth/clear-cache/**"); DEFAULT_SKIP_URL.add("/oauth/user-info"); - DEFAULT_SKIP_URL.add("/oauth/render"); - DEFAULT_SKIP_URL.add("/oauth/callback"); - DEFAULT_SKIP_URL.add("/oauth/revoke"); - DEFAULT_SKIP_URL.add("/oauth/refresh"); + DEFAULT_SKIP_URL.add("/oauth/render/**"); + DEFAULT_SKIP_URL.add("/oauth/callback/**"); + DEFAULT_SKIP_URL.add("/oauth/revoke/**"); + DEFAULT_SKIP_URL.add("/oauth/refresh/**"); DEFAULT_SKIP_URL.add("/token/**"); - DEFAULT_SKIP_URL.add("/actuator/health/**"); + DEFAULT_SKIP_URL.add("/actuator/**"); DEFAULT_SKIP_URL.add("/v2/api-docs/**"); DEFAULT_SKIP_URL.add("/auth/**"); DEFAULT_SKIP_URL.add("/log/**"); diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthSecure.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthSecure.java new file mode 100644 index 000000000..2e69987b0 --- /dev/null +++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthSecure.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.gateway.provider; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 自定义授权规则 + * + * @author Chill + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AuthSecure { + /** + * 请求路径 + */ + private String pattern; + +} diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/BasicSecure.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/BasicSecure.java new file mode 100644 index 000000000..bbd62c260 --- /dev/null +++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/BasicSecure.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.gateway.provider; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 基础授权规则 + * + * @author Chill + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BasicSecure { + /** + * 请求路径 + */ + private String pattern; + +} diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/SignSecure.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/SignSecure.java new file mode 100644 index 000000000..14b2ff915 --- /dev/null +++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/SignSecure.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.gateway.provider; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 签名授权规则 + * + * @author Chill + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SignSecure { + /** + * 请求路径 + */ + private String pattern; + +} diff --git a/blade-gateway/src/main/resources/application-dev.yml b/blade-gateway/src/main/resources/application-dev.yml index 05b6e03e4..b8eaf546c 100644 --- a/blade-gateway/src/main/resources/application-dev.yml +++ b/blade-gateway/src/main/resources/application-dev.yml @@ -1,10 +1,11 @@ blade: #多团队协作服务配置 - ribbon: - rule: - #开启配置 - enabled: true - #负载均衡优先调用的ip段 - prior-ip-pattern: - - 192.168.0.* - - 127.0.0.1 + loadbalancer: + #开启配置 + enabled: true + #灰度版本 + #version: 3.0.0 + #负载均衡优先调用的ip段 + prior-ip-pattern: + - 192.168.0.* + - 127.0.0.1 diff --git a/blade-gateway/src/main/resources/bootstrap.yml b/blade-gateway/src/main/resources/bootstrap.yml index 63cc8f331..5c9f4fd54 100644 --- a/blade-gateway/src/main/resources/bootstrap.yml +++ b/blade-gateway/src/main/resources/bootstrap.yml @@ -10,14 +10,3 @@ spring: loadbalancer: retry: enabled: true - -# 聚合文档配置 -blade: - document: - resources: - - name: 授权模块 - location: /blade-auth - - name: 工作台模块 - location: /blade-desk - - name: 系统模块 - location: /blade-system diff --git a/blade-service-api/blade-demo-api/pom.xml b/blade-service-api/blade-demo-api/pom.xml index 10b8cbe81..1f06c5e24 100644 --- a/blade-service-api/blade-demo-api/pom.xml +++ b/blade-service-api/blade-demo-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-service-api/pom.xml b/blade-service-api/pom.xml index 9b1cae540..34e4270af 100644 --- a/blade-service-api/pom.xml +++ b/blade-service-api/pom.xml @@ -5,14 +5,14 @@ BladeX-Biz org.springblade - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 blade-service-api ${project.artifactId} - 2.9.1.RELEASE + 3.0.0.RELEASE pom BladeX 微服务API集合 diff --git a/blade-service/blade-demo/pom.xml b/blade-service/blade-demo/pom.xml index e4a4bd014..d352a4958 100644 --- a/blade-service/blade-demo/pom.xml +++ b/blade-service/blade-demo/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-service - 2.9.1.RELEASE + 3.0.0.RELEASE 4.0.0 diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java b/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java index f559ba03b..f2a0d2e73 100644 --- a/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java +++ b/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java @@ -16,16 +16,16 @@ */ package com.example.demo; +import org.springblade.core.cloud.client.BladeCloudApplication; import org.springblade.core.launch.BladeApplication; import org.springblade.core.launch.constant.AppConstant; -import org.springframework.cloud.client.SpringCloudApplication; /** * Demo启动器 * * @author Chill */ -@SpringCloudApplication +@BladeCloudApplication public class DemoApplication { public static void main(String[] args) { diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java b/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java index 6f48b8c08..468f33eb9 100644 --- a/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java +++ b/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java @@ -29,7 +29,7 @@ import org.springframework.context.annotation.Configuration; * * @author Chill */ -@Configuration +@Configuration(proxyBeanMethods = false) @ComponentScan({"org.springblade", "com.example"}) @EnableFeignClients({"org.springblade", "com.example"}) @MapperScan({"org.springblade.**.mapper.**", "com.example.**.mapper.**"}) diff --git a/blade-service/blade-demo/src/test/java/BladeDemoTest.java b/blade-service/blade-demo/src/test/java/BladeDemoTest.java index d05fc2914..fbe539bc4 100644 --- a/blade-service/blade-demo/src/test/java/BladeDemoTest.java +++ b/blade-service/blade-demo/src/test/java/BladeDemoTest.java @@ -1,9 +1,9 @@ import com.example.demo.DemoApplication; import com.example.demo.service.INoticeService; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springblade.core.test.BladeBootTest; -import org.springblade.core.test.BladeSpringRunner; +import org.springblade.core.test.BladeSpringExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -12,7 +12,7 @@ import org.springframework.boot.test.context.SpringBootTest; * * @author Chill */ -@RunWith(BladeSpringRunner.class) +@ExtendWith(BladeSpringExtension.class) @SpringBootTest(classes = DemoApplication.class) @BladeBootTest(appName = "blade-demo", profile = "test", enableLoader = true) public class BladeDemoTest { diff --git a/blade-service/pom.xml b/blade-service/pom.xml index 0374b2b28..aacfe6d92 100644 --- a/blade-service/pom.xml +++ b/blade-service/pom.xml @@ -7,12 +7,12 @@ org.springblade BladeX-Biz - 2.9.1.RELEASE + 3.0.0.RELEASE blade-service ${project.artifactId} - 2.9.1.RELEASE + 3.0.0.RELEASE pom BladeX 微服务集合 diff --git a/doc/nacos/blade.yaml b/doc/nacos/blade.yaml index 728f9052d..03363b3dc 100644 --- a/doc/nacos/blade.yaml +++ b/doc/nacos/blade.yaml @@ -31,33 +31,6 @@ feign: httpclient: enabled: false -#hystrix配置 -hystrix: - threadpool: - default: - coreSize: 300 - maxQueueSize: 1000 - queueSizeRejectionThreshold: 800 - command: - default: - execution: - isolation: - thread: - timeoutInMilliseconds: 5000 - -#ribbon配置 -ribbon: - #对当前实例的重试次数 - MaxAutoRetries: 1 - #切换实例的重试次数 - MaxAutoRetriesNextServer: 2 - #请求处理的超时时间 - ReadTimeout: 60000 - #请求连接的超时时间 - ConnectTimeout: 60000 - #对所有操作请求都进行重试 - OkToRetryOnAllOperations: true - #对外暴露端口 management: endpoints: @@ -95,7 +68,7 @@ knife4j: swagger: title: BladeX 接口文档系统 description: BladeX 接口文档系统 - version: 2.9.1.RELEASE + version: 3.0.0.RELEASE license: Powered By BladeX license-url: https://bladex.vip terms-of-service-url: https://bladex.vip diff --git a/pom.xml b/pom.xml index 16dedeec2..54cc3b2f4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,11 +5,11 @@ org.springblade BladeX-Biz - 2.9.1.RELEASE + 3.0.0.RELEASE pom - 2.9.1.RELEASE + 3.0.0.RELEASE 1.8 3.8.1 @@ -19,8 +19,8 @@ 6.4.2 2.7.8 - 2.3.12.RELEASE - Hoxton.SR12 + 2.7.1 + 2021.0.3 Cairo-SR8 diff --git a/script/docker/app/.env b/script/docker/app/.env index bc4947aba..f4611b45c 100644 --- a/script/docker/app/.env +++ b/script/docker/app/.env @@ -1,2 +1,2 @@ REGISTER=192.168.0.157/blade -TAG=2.9.1.RELEASE +TAG=3.0.0.RELEASE