diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java
index 43a1e4ddf..48d423d2c 100644
--- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java
+++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java
@@ -66,4 +66,9 @@ public interface CommonConstant {
* 后端工程名
*/
String BACK_END_PROJECT = "pigx";
+
+ /**
+ * 路由存放
+ */
+ String ROUTE_KEY = "gateway_route_key";
}
diff --git a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/LogAutoConfiguration.java b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/LogAutoConfiguration.java
index eaa365b79..846bcd0e1 100644
--- a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/LogAutoConfiguration.java
+++ b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/LogAutoConfiguration.java
@@ -22,9 +22,9 @@ package com.pig4cloud.pigx.common.log;
import com.pig4cloud.pigx.admin.api.feign.RemoteLogService;
import com.pig4cloud.pigx.common.log.aspect.SysLogAspect;
import com.pig4cloud.pigx.common.log.event.SysLogListener;
+import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
-import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -35,8 +35,8 @@ import org.springframework.context.annotation.Configuration;
*/
@Configuration
@AllArgsConstructor
+@EnablePigxFeignClients
@ConditionalOnWebApplication
-@EnableFeignClients({"com.pig4cloud.pigx.admin.api.feign"})
public class LogAutoConfiguration {
private final RemoteLogService remoteLogService;
diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/BaseResourceServerConfigurerAdapter.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/BaseResourceServerConfigurerAdapter.java
index bf49a3f6d..8da52bf60 100644
--- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/BaseResourceServerConfigurerAdapter.java
+++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/BaseResourceServerConfigurerAdapter.java
@@ -59,7 +59,7 @@ public abstract class BaseResourceServerConfigurerAdapter extends ResourceServer
/**
* 提供子类重写
*
- * 1. 不重写,默认支持获取雍熙
+ * 1. 不重写,默认支持获取用户名
* 2. 重写notGetUser,提供性能
*
* see codegen ResourceServerConfigurer
diff --git a/pigx-config/src/main/resources/config/pigx-auth-dev.yml b/pigx-config/src/main/resources/config/pigx-auth-dev.yml
index 4ade36d4d..3d0fff572 100644
--- a/pigx-config/src/main/resources/config/pigx-auth-dev.yml
+++ b/pigx-config/src/main/resources/config/pigx-auth-dev.yml
@@ -5,4 +5,4 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
- url: jdbc:mysql://pigx-mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+ url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
diff --git a/pigx-config/src/main/resources/config/pigx-codegen-dev.yml b/pigx-config/src/main/resources/config/pigx-codegen-dev.yml
index 6dceea95d..a0b70b1ab 100644
--- a/pigx-config/src/main/resources/config/pigx-codegen-dev.yml
+++ b/pigx-config/src/main/resources/config/pigx-codegen-dev.yml
@@ -13,6 +13,6 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
- url: jdbc:mysql://pigx-mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+ url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
resources:
static-locations: classpath:/static/,classpath:/views/
diff --git a/pigx-config/src/main/resources/config/pigx-daemon-dev.yml b/pigx-config/src/main/resources/config/pigx-daemon-dev.yml
index 22f27306f..73afe508e 100644
--- a/pigx-config/src/main/resources/config/pigx-daemon-dev.yml
+++ b/pigx-config/src/main/resources/config/pigx-daemon-dev.yml
@@ -14,7 +14,7 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
- url: jdbc:mysql://pigx-mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+ url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
elasticjob:
# 分布式任务协调依赖zookeeper
zookeeper:
diff --git a/pigx-config/src/main/resources/config/pigx-upms-dev.yml b/pigx-config/src/main/resources/config/pigx-upms-dev.yml
index 1f5ea33bc..eb1d35026 100644
--- a/pigx-config/src/main/resources/config/pigx-upms-dev.yml
+++ b/pigx-config/src/main/resources/config/pigx-upms-dev.yml
@@ -13,7 +13,7 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
- url: jdbc:mysql://pigx-mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
+ url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
# swagger相关配置,覆盖全局配置
swagger:
diff --git a/pigx-gateway/pom.xml b/pigx-gateway/pom.xml
index 1e518691f..834819251 100644
--- a/pigx-gateway/pom.xml
+++ b/pigx-gateway/pom.xml
@@ -59,6 +59,12 @@
pigx-common-core
${pigx.version}
+
+
+ com.pig4cloud
+ pigx-common-cache
+ ${pigx.version}
+
io.springfox
diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/SwaggerProvider.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/SwaggerProvider.java
index d8b8a02f0..261ff8cc6 100644
--- a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/SwaggerProvider.java
+++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/SwaggerProvider.java
@@ -37,7 +37,7 @@ import java.util.List;
@Primary
@AllArgsConstructor
public class SwaggerProvider implements SwaggerResourcesProvider {
- public static final String API_URI = "/v2/api-docs";
+ private static final String API_URI = "/v2/api-docs";
private final RouteLocator routeLocator;
private final GatewayProperties gatewayProperties;
diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/HttpBasicGatewayFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/HttpBasicGatewayFilter.java
new file mode 100644
index 000000000..c4f106975
--- /dev/null
+++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/HttpBasicGatewayFilter.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.gateway.filter;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cloud.gateway.filter.GatewayFilter;
+import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.stereotype.Component;
+import org.springframework.web.server.ServerWebExchange;
+
+/**
+ * @author lengleng
+ * @date 2018/10/30
+ *
+ * 自定义basic认证,针对特殊场景使用
+ */
+@Slf4j
+@Component
+public class HttpBasicGatewayFilter extends AbstractGatewayFilterFactory {
+ @Override
+ public GatewayFilter apply(Object config) {
+ return (exchange, chain) -> {
+ if (hasAuth(exchange)) {
+ return chain.filter(exchange);
+ } else {
+ ServerHttpResponse response = exchange.getResponse();
+ response.setStatusCode(HttpStatus.UNAUTHORIZED);
+ response.getHeaders().add(HttpHeaders.WWW_AUTHENTICATE, "Basic Realm=\"pigx\"");
+ return response.setComplete();
+ }
+ };
+ }
+
+ /**
+ * 简单的basic认证
+ *
+ * @param exchange 上下文
+ * @return 是否有权限
+ */
+ private boolean hasAuth(ServerWebExchange exchange) {
+ ServerHttpRequest request = exchange.getRequest();
+ String auth = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
+ log.info("Basic认证信息为:{}", auth);
+ return true;
+ }
+
+}
diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ValidateCodeGatewayFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ValidateCodeGatewayFilter.java
index a32118d78..41b14aefc 100644
--- a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ValidateCodeGatewayFilter.java
+++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ValidateCodeGatewayFilter.java
@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
@@ -89,7 +90,7 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
*/
public static String[] extractAndDecodeHeader(ServerHttpRequest request)
throws IOException, CheckedException {
- String header = request.getHeaders().getFirst("Authorization");
+ String header = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
if (header == null || !header.startsWith(BASIC_)) {
throw new CheckedException("请求头中client信息为空");
diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/support/DynamicRouteEndpoint.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/support/DynamicRouteEndpoint.java
new file mode 100644
index 000000000..8196e5deb
--- /dev/null
+++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/support/DynamicRouteEndpoint.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.gateway.support;
+
+import com.pig4cloud.pigx.common.core.util.R;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cloud.gateway.route.RouteDefinition;
+import org.springframework.web.bind.annotation.*;
+import reactor.core.publisher.Mono;
+
+import java.util.Map;
+
+/**
+ * @author lengleng
+ * @date 2018/10/31
+ *
+ * 动态路由业务端点
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@RequestMapping("/route")
+public class DynamicRouteEndpoint {
+ private final DynamicRouteHandler dynamicRouteHandler;
+
+ /**
+ * 获取当前定义的路由信息
+ *
+ * @return {"id":"RouteDefinition"}
+ */
+ @GetMapping
+ public Mono