diff --git a/fizz-bootstrap/pom.xml b/fizz-bootstrap/pom.xml
index a449b54..7d8fa55 100644
--- a/fizz-bootstrap/pom.xml
+++ b/fizz-bootstrap/pom.xml
@@ -12,10 +12,10 @@
com.fizzgate
fizz-bootstrap
- 2.0.0-beta2
+ 2.0.0-beta3
- 2.0.0-beta2
+ 2.0.0-beta3
1.8
5.2.14.RELEASE
Dysprosium-SR19
diff --git a/fizz-common/pom.xml b/fizz-common/pom.xml
index e0f4818..cfa4775 100644
--- a/fizz-common/pom.xml
+++ b/fizz-common/pom.xml
@@ -5,7 +5,7 @@
fizz-gateway-community
com.fizzgate
- 2.0.0-beta2
+ 2.0.0-beta3
../pom.xml
4.0.0
diff --git a/fizz-core/pom.xml b/fizz-core/pom.xml
index 286766a..bfd7bac 100644
--- a/fizz-core/pom.xml
+++ b/fizz-core/pom.xml
@@ -5,7 +5,7 @@
fizz-gateway-community
com.fizzgate
- 2.0.0-beta2
+ 2.0.0-beta3
../pom.xml
4.0.0
diff --git a/fizz-core/src/main/java/we/config/SystemConfig.java b/fizz-core/src/main/java/we/config/SystemConfig.java
index ec0d3ea..b0d1deb 100644
--- a/fizz-core/src/main/java/we/config/SystemConfig.java
+++ b/fizz-core/src/main/java/we/config/SystemConfig.java
@@ -44,19 +44,23 @@ public class SystemConfig {
private static final Logger log = LoggerFactory.getLogger(SystemConfig.class);
- public static final String DEFAULT_GATEWAY_PREFIX = "/proxy";
+ public static final String DEFAULT_GATEWAY_PREFIX = "/proxy";
- public static final String DEFAULT_GATEWAY_TEST_PREFIX = "/_proxytest";
+ public static final String DEFAULT_GATEWAY_TEST_PREFIX = "/_proxytest";
- public String gatewayPrefix = DEFAULT_GATEWAY_PREFIX;
+ public static final String DEFAULT_GATEWAY_TEST_PREFIX0 = "/_proxytest/";
- public List appHeaders = Stream.of("fizz-appid").collect(Collectors.toList());
+ public String gatewayPrefix = DEFAULT_GATEWAY_PREFIX;
- public List signHeaders = Stream.of("fizz-sign") .collect(Collectors.toList());
+ public List appHeaders = Stream.of("fizz-appid").collect(Collectors.toList());
- public List timestampHeaders = Stream.of("fizz-ts") .collect(Collectors.toList());
+ public List signHeaders = Stream.of("fizz-sign") .collect(Collectors.toList());
+
+ public List timestampHeaders = Stream.of("fizz-ts") .collect(Collectors.toList());
- public List proxySetHeaders = new ArrayList<>();
+ public List proxySetHeaders = new ArrayList<>();
+
+ public boolean aggregateTestAuth = false;
@NacosValue(value = "${gateway.aggr.proxy_set_headers:}", autoRefreshed = true)
@@ -112,6 +116,13 @@ public class SystemConfig {
log.info("timestamp headers: " + timestampHeaders);
}
+ @NacosValue(value = "${aggregate-test-auth:false}", autoRefreshed = true)
+ @Value( "${aggregate-test-auth:false}" )
+ public void setAggregateTestAuth(boolean b) {
+ aggregateTestAuth = b;
+ log.info("aggregate test auth: " + aggregateTestAuth);
+ }
+
// TODO: below to X
@Value("${log.response-body:false}")
diff --git a/fizz-core/src/main/java/we/filter/AggregateFilter.java b/fizz-core/src/main/java/we/filter/AggregateFilter.java
index af07fdc..7b70708 100644
--- a/fizz-core/src/main/java/we/filter/AggregateFilter.java
+++ b/fizz-core/src/main/java/we/filter/AggregateFilter.java
@@ -17,17 +17,9 @@
package we.filter;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.annotation.Resource;
-
+import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.api.config.annotation.NacosValue;
+import io.netty.buffer.UnpooledByteBufAllocator;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,13 +36,10 @@ import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
-
-import com.alibaba.fastjson.JSON;
-
-import io.netty.buffer.UnpooledByteBufAllocator;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
+import we.config.SystemConfig;
import we.constants.CommonConstants;
import we.fizz.AggregateResource;
import we.fizz.AggregateResult;
@@ -63,6 +52,14 @@ import we.util.Constants;
import we.util.MapUtil;
import we.util.WebUtils;
+import javax.annotation.Resource;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
/**
* @author Francis Dong
*/
@@ -81,26 +78,44 @@ public class AggregateFilter implements WebFilter {
@Value("${need-auth:true}")
private boolean needAuth;
+ @Resource
+ private SystemConfig systemConfig;
+
@Override
public Mono filter(ServerWebExchange exchange, WebFilterChain chain) {
String serviceId = WebUtils.getBackendService(exchange);
- if ( serviceId == null || (ApiConfig.Type.SERVICE_AGGREGATE != WebUtils.getApiConfigType(exchange) && needAuth) ) {
+ if (serviceId == null) {
return chain.filter(exchange);
+ } else {
+ byte act = WebUtils.getApiConfigType(exchange);
+ if (act == ApiConfig.Type.UNDEFINED) {
+ String p = exchange.getRequest().getPath().value();
+ if (StringUtils.startsWith(p, SystemConfig.DEFAULT_GATEWAY_TEST_PREFIX0)) {
+ if (systemConfig.aggregateTestAuth) {
+ return chain.filter(exchange);
+ }
+ } else if (needAuth) {
+ return chain.filter(exchange);
+ }
+ } else if (act != ApiConfig.Type.SERVICE_AGGREGATE) {
+ return chain.filter(exchange);
+ }
}
long start = System.currentTimeMillis();
ServerHttpRequest request = exchange.getRequest();
ServerHttpResponse serverHttpResponse = exchange.getResponse();
- String path = WebUtils.getClientReqPathPrefix(exchange) + serviceId + WebUtils.getBackendPath(exchange);
+ String clientReqPathPrefix = WebUtils.getClientReqPathPrefix(exchange);
+ String path = clientReqPathPrefix + serviceId + WebUtils.getBackendPath(exchange);
String method = request.getMethodValue();
if (HttpMethod.HEAD.matches(method.toUpperCase())) {
method = HttpMethod.GET.name();
}
AggregateResource aggregateResource = configLoader.matchAggregateResource(method, path);
if (aggregateResource == null) {
- if (WebUtils.getApiConfigType(exchange) == ApiConfig.Type.SERVICE_AGGREGATE) {
+ if (SystemConfig.DEFAULT_GATEWAY_TEST_PREFIX0.equals(clientReqPathPrefix) || WebUtils.getApiConfigType(exchange) == ApiConfig.Type.SERVICE_AGGREGATE) {
return WebUtils.responseError(exchange, HttpStatus.INTERNAL_SERVER_ERROR.value(), "no aggregate resource: " + path);
} else {
return chain.filter(exchange);
diff --git a/fizz-core/src/main/java/we/plugin/auth/ApiConfigService.java b/fizz-core/src/main/java/we/plugin/auth/ApiConfigService.java
index c73b820..7df0d68 100644
--- a/fizz-core/src/main/java/we/plugin/auth/ApiConfigService.java
+++ b/fizz-core/src/main/java/we/plugin/auth/ApiConfigService.java
@@ -199,12 +199,8 @@ public class ApiConfigService {
YES (null),
- NO_SERVICE_CONFIG ("no service config"),
-
ROUTE_NOT_FOUND ("route not found"),
- GATEWAY_GROUP_CANT_PROXY_API ("gateway group cant proxy api"),
-
APP_NOT_IN_API_LEGAL_APPS ("app not in api legal apps"),
IP_NOT_IN_WHITE_LIST ("ip not in white list"),
@@ -288,29 +284,26 @@ public class ApiConfigService {
private Mono