Dedicated line (#376)

Dedicated Line init
This commit is contained in:
hongqiaowei
2021-11-16 15:18:27 +08:00
committed by GitHub
parent 3da394f381
commit a10c236a6e
53 changed files with 794 additions and 896 deletions

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId>
<version>2.3.3-beta6</version>
<version>2.3.4-beta1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -258,7 +258,7 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>

View File

@@ -19,15 +19,19 @@ package we.plugin.dedicatedline.auth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import we.api.pairing.ApiPairingDocSetService;
import we.config.SystemConfig;
import we.dedicated_line.DedicatedLineService;
import we.plugin.FizzPluginFilter;
import we.plugin.FizzPluginFilterChain;
import we.util.ReactorUtils;
@@ -46,21 +50,27 @@ public class DedicatedLineApiAuthPluginFilter implements FizzPluginFilter {
private static final Logger log = LoggerFactory.getLogger(DedicatedLineApiAuthPluginFilter.class);
public static final String DEDICATED_LINE_API_AUTH_PLUGIN_FILTER = "dedicatedLineCodecPlugin";
@Resource
private ApiPairingDocSetService apiPairingDocSetService;
private DedicatedLineService dedicatedLineService;
public static final String DEDICATED_LINE_API_AUTH_PLUGIN_FILTER = "dedicatedLineCodecPlugin";
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Mono<Void> filter(ServerWebExchange exchange, Map<String, Object> config) {
String traceId = WebUtils.getTraceId(exchange);
try {
String appId = WebUtils.getAppId(exchange);
String dedicatedLineId = WebUtils.getDedicatedLineId(exchange);
String service = WebUtils.getClientService(exchange);
String path = WebUtils.getClientReqPath(exchange);
HttpMethod method = exchange.getRequest().getMethod();
if (apiPairingDocSetService.existsDocSetMatch(appId, method, service, path)) {
if (dedicatedLineService.auth(dedicatedLineId, method, service, path)) {
// Go to next plugin
Mono next = FizzPluginFilterChain.next(exchange);
return next.defaultIfEmpty(ReactorUtils.NULL).flatMap(nil -> {