Browse Source

🎉 3.0.0.RELEASE 升级 SpringCloud 2021, SpringBoot 2.7

test
smallchill 3 years ago
parent
commit
7ba0443f60
  1. 4
      blade-biz-common/pom.xml
  2. 2
      blade-biz-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java
  3. 2
      blade-example-api/blade-dubbo-provider-api/pom.xml
  4. 2
      blade-example-api/blade-stream-api/pom.xml
  5. 4
      blade-example-api/pom.xml
  6. 2
      blade-example/blade-dubbo-consumer/pom.xml
  7. 6
      blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/DubboConsumerApplication.java
  8. 2
      blade-example/blade-dubbo-consumer/src/main/java/org/springblade/example/consumer/config/ConsumerConfiguration.java
  9. 2
      blade-example/blade-dubbo-provider/pom.xml
  10. 6
      blade-example/blade-dubbo-provider/src/main/java/org/springblade/example/provider/DubboProviderApplication.java
  11. 2
      blade-example/blade-easypoi/pom.xml
  12. 2
      blade-example/blade-easypoi/src/main/java/org/springblade/example/poi/test/web/cfg/Cfg.java
  13. 2
      blade-example/blade-mq-kafka/pom.xml
  14. 2
      blade-example/blade-mq-kafka/src/main/java/org/springblade/example/mq/kafka/config/KafkaConfiguration.java
  15. 2
      blade-example/blade-mq-rabbit/pom.xml
  16. 2
      blade-example/blade-mq-rabbit/src/main/java/org/springblade/example/mq/rabbit/config/RabbitMqConfiguration.java
  17. 2
      blade-example/blade-seata-order/pom.xml
  18. 2
      blade-example/blade-seata-storage/pom.xml
  19. 2
      blade-example/blade-stream-consumer/pom.xml
  20. 2
      blade-example/blade-stream-provider/pom.xml
  21. 2
      blade-example/blade-websocket/pom.xml
  22. 2
      blade-example/blade-websocket/src/main/java/org/springblade/websocket/config/WebSocketConfig.java
  23. 4
      blade-example/pom.xml
  24. 54
      blade-gateway/pom.xml
  25. 10
      blade-gateway/src/main/java/org/springblade/gateway/GateWayApplication.java
  26. 5
      blade-gateway/src/main/java/org/springblade/gateway/config/ErrorHandlerConfiguration.java
  27. 4
      blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java
  28. 11
      blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java
  29. 8
      blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalRequestLogFilter.java
  30. 6
      blade-gateway/src/main/java/org/springblade/gateway/filter/GlobalResponseLogFilter.java
  31. 18
      blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java
  32. 12
      blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java
  33. 37
      blade-gateway/src/main/java/org/springblade/gateway/provider/AuthSecure.java
  34. 37
      blade-gateway/src/main/java/org/springblade/gateway/provider/BasicSecure.java
  35. 37
      blade-gateway/src/main/java/org/springblade/gateway/provider/SignSecure.java
  36. 5
      blade-gateway/src/main/resources/application-dev.yml
  37. 11
      blade-gateway/src/main/resources/bootstrap.yml
  38. 2
      blade-service-api/blade-demo-api/pom.xml
  39. 4
      blade-service-api/pom.xml
  40. 2
      blade-service/blade-demo/pom.xml
  41. 4
      blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java
  42. 2
      blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java
  43. 8
      blade-service/blade-demo/src/test/java/BladeDemoTest.java
  44. 4
      blade-service/pom.xml
  45. 29
      doc/nacos/blade.yaml
  46. 8
      pom.xml
  47. 2
      script/docker/app/.env

4
blade-biz-common/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -21,7 +21,7 @@
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-ribbon</artifactId>
<artifactId>blade-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>

2
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 {

2
blade-example-api/blade-dubbo-provider-api/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-example-api/blade-stream-api/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

4
blade-example-api/pom.xml

@ -5,13 +5,13 @@
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-example-api</artifactId>
<name>${project.artifactId}</name>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
<packaging>pom</packaging>
<description>BladeX 微服务范例API集合</description>

2
blade-example/blade-dubbo-consumer/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

6
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) {

2
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

2
blade-example/blade-dubbo-provider/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

6
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) {

2
blade-example/blade-easypoi/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
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

2
blade-example/blade-mq-kafka/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
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

2
blade-example/blade-mq-rabbit/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
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

2
blade-example/blade-seata-order/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-example/blade-seata-storage/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-example/blade-stream-consumer/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-example/blade-stream-provider/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
blade-example/blade-websocket/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-example</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2
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 {

4
blade-example/pom.xml

@ -5,13 +5,13 @@
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-example</artifactId>
<name>${project.artifactId}</name>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
<packaging>pom</packaging>
<description>BladeX 微服务范例集合</description>

54
blade-gateway/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -40,6 +40,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-metrics</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-jwt</artifactId>
@ -53,58 +57,22 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<!--Hystrix-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!--Swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-ui</artifactId>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<!--<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>-->
</dependencies>
<build>

10
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) {

5
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

4
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 = "*";

11
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<Void> 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<Void> unAuth(ServerHttpResponse resp, String msg) {

8
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());
}
});

6
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");

18
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<String> skipUrl = new ArrayList<>();
/**
* 自定义授权配置
*/
private final List<AuthSecure> auth = new ArrayList<>();
/**
* 基础认证配置
*/
private final List<BasicSecure> basic = new ArrayList<>();
/**
* 签名认证配置
*/
private final List<SignSecure> sign = new ArrayList<>();
}

12
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<String> 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/**");

37
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;
}

37
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;
}

37
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;
}

5
blade-gateway/src/main/resources/application-dev.yml

@ -1,9 +1,10 @@
blade:
#多团队协作服务配置
ribbon:
rule:
loadbalancer:
#开启配置
enabled: true
#灰度版本
#version: 3.0.0
#负载均衡优先调用的ip段
prior-ip-pattern:
- 192.168.0.*

11
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

2
blade-service-api/blade-demo-api/pom.xml

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

4
blade-service-api/pom.xml

@ -5,14 +5,14 @@
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-service-api</artifactId>
<name>${project.artifactId}</name>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
<packaging>pom</packaging>
<description>BladeX 微服务API集合</description>

2
blade-service/blade-demo/pom.xml

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-service</artifactId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

4
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) {

2
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.**"})

8
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 {

4
blade-service/pom.xml

@ -7,12 +7,12 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>BladeX-Biz</artifactId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
</parent>
<artifactId>blade-service</artifactId>
<name>${project.artifactId}</name>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
<packaging>pom</packaging>
<description>BladeX 微服务集合</description>

29
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

8
pom.xml

@ -5,11 +5,11 @@
<groupId>org.springblade</groupId>
<artifactId>BladeX-Biz</artifactId>
<version>2.9.1.RELEASE</version>
<version>3.0.0.RELEASE</version>
<packaging>pom</packaging>
<properties>
<bladex.project.version>2.9.1.RELEASE</bladex.project.version>
<bladex.project.version>3.0.0.RELEASE</bladex.project.version>
<java.version>1.8</java.version>
<maven.plugin.version>3.8.1</maven.plugin.version>
@ -19,8 +19,8 @@
<flowable.version>6.4.2</flowable.version>
<dubbo.version>2.7.8</dubbo.version>
<spring.boot.version>2.3.12.RELEASE</spring.boot.version>
<spring.cloud.version>Hoxton.SR12</spring.cloud.version>
<spring.boot.version>2.7.1</spring.boot.version>
<spring.cloud.version>2021.0.3</spring.cloud.version>
<spring.platform.version>Cairo-SR8</spring.platform.version>
<!-- 推荐使用Harbor -->

2
script/docker/app/.env

@ -1,2 +1,2 @@
REGISTER=192.168.0.157/blade
TAG=2.9.1.RELEASE
TAG=3.0.0.RELEASE

Loading…
Cancel
Save