Release 2.2.0-beta9

This commit is contained in:
hongqiaowei
2021-07-07 14:20:01 +08:00
parent c9fc399013
commit f26cd1530e
8 changed files with 33 additions and 12 deletions

View File

@@ -12,7 +12,7 @@
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<artifactId>fizz-bootstrap</artifactId> <artifactId>fizz-bootstrap</artifactId>
<version>2.2.0-beta8</version> <version>2.2.0-beta9</version>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<version>2.2.0-beta8</version> <version>2.2.0-beta9</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<version>2.2.0-beta8</version> <version>2.2.0-beta9</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -17,15 +17,13 @@
package we.filter; package we.filter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilterChain; import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import we.plugin.FixedPluginFilter;
import we.plugin.FizzPluginFilterChain; import we.plugin.FizzPluginFilterChain;
import we.plugin.PluginFilter; import we.plugin.PluginFilter;
import we.plugin.auth.ApiConfig; import we.plugin.auth.ApiConfig;
@@ -37,6 +35,7 @@ import we.util.WebUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
@@ -75,15 +74,22 @@ public class PreprocessFilter extends FizzWebFilter {
if (authRes instanceof ApiConfig) { if (authRes instanceof ApiConfig) {
ApiConfig ac = (ApiConfig) authRes; ApiConfig ac = (ApiConfig) authRes;
afterAuth(exchange, ac); afterAuth(exchange, ac);
m = executeFixedPluginFilters(exchange);
m = m.defaultIfEmpty(ReactorUtils.NULL);
if (ac.pluginConfigs == null || ac.pluginConfigs.isEmpty()) { if (ac.pluginConfigs == null || ac.pluginConfigs.isEmpty()) {
return m.flatMap(func(exchange, chain)); return m.flatMap(func(exchange, chain));
} else { } else {
return m.flatMap(
nil -> {
eas.put(FizzPluginFilterChain.WEB_FILTER_CHAIN, chain); eas.put(FizzPluginFilterChain.WEB_FILTER_CHAIN, chain);
return FizzPluginFilterChain.next(exchange); return FizzPluginFilterChain.next(exchange);
} }
);
}
} else if (authRes == ApiConfigService.Access.YES) { } else if (authRes == ApiConfigService.Access.YES) {
afterAuth(exchange, null); afterAuth(exchange, null);
return m.flatMap(func(exchange, chain)); m = executeFixedPluginFilters(exchange);
return m.defaultIfEmpty(ReactorUtils.NULL).flatMap(func(exchange, chain));
} else { } else {
String err = null; String err = null;
if (authRes instanceof ApiConfigService.Access) { if (authRes instanceof ApiConfigService.Access) {
@@ -138,4 +144,18 @@ public class PreprocessFilter extends FizzWebFilter {
return chain.filter(exchange); return chain.filter(exchange);
}; };
} }
private Mono<Void> executeFixedPluginFilters(ServerWebExchange exchange) {
Mono vm = Mono.empty();
List<FixedPluginFilter> fixedPluginFilters = FixedPluginFilter.getPluginFilters();
for (byte i = 0; i < fixedPluginFilters.size(); i++) {
FixedPluginFilter fpf = fixedPluginFilters.get(i);
vm = vm.defaultIfEmpty(ReactorUtils.NULL).flatMap(
v -> {
return fpf.filter(exchange, null, null);
}
);
}
return vm;
}
} }

View File

@@ -29,6 +29,7 @@ import java.util.*;
* @author hongqiaowei * @author hongqiaowei
*/ */
@Deprecated
public abstract class FixedPluginFilter extends PluginFilter { public abstract class FixedPluginFilter extends PluginFilter {
private static final Logger log = LoggerFactory.getLogger(FixedPluginFilter.class); private static final Logger log = LoggerFactory.getLogger(FixedPluginFilter.class);

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<version>2.2.0-beta8</version> <version>2.2.0-beta9</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<version>2.2.0-beta8</version> <version>2.2.0-beta9</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -31,7 +31,7 @@
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<name>${project.artifactId}</name> <name>${project.artifactId}</name>
<description>fizz gateway community</description> <description>fizz gateway community</description>
<version>2.2.0-beta8</version> <version>2.2.0-beta9</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>fizz-common</module> <module>fizz-common</module>