|
|
|
@ -33,7 +33,9 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
|
|
|
import org.springframework.cloud.gateway.filter.GlobalFilter; |
|
|
|
|
import org.springframework.core.Ordered; |
|
|
|
|
import org.springframework.core.io.buffer.DataBuffer; |
|
|
|
|
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.util.AntPathMatcher; |
|
|
|
@ -61,6 +63,10 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|
|
|
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
|
|
|
|
//校验 Token 放行
|
|
|
|
|
String originalRequestUrl = RequestProvider.getOriginalRequestUrl(exchange); |
|
|
|
|
// ServerHttpRequest request = exchange.getRequest();
|
|
|
|
|
|
|
|
|
|
// HttpHeaders headers = request.getHeaders();
|
|
|
|
|
// headers.add("hwy_req","1");
|
|
|
|
|
String path = exchange.getRequest().getURI().getPath(); |
|
|
|
|
if (isSkip(path) || isSkip(originalRequestUrl)) { |
|
|
|
|
return chain.filter(exchange); |
|
|
|
@ -88,6 +94,8 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|
|
|
|
return unAuth(resp, "令牌已失效"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return chain.filter(exchange); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|