fix 修复 内网鉴权Filter 优先级问题 导致websocket连接失败

2.X
疯狂的狮子li 2 years ago
parent 8bd8fcab89
commit 2a5a73658d

@ -3,6 +3,7 @@ package com.ruoyi.gateway.filter;
import cn.dev33.satoken.same.SaSameUtil; import cn.dev33.satoken.same.SaSameUtil;
import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
@ -14,7 +15,7 @@ import reactor.core.publisher.Mono;
* @author Lion Li * @author Lion Li
*/ */
@Component @Component
public class ForwardAuthFilter implements GlobalFilter { public class ForwardAuthFilter implements GlobalFilter, Ordered {
@Override @Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest newRequest = exchange ServerHttpRequest newRequest = exchange
@ -26,5 +27,10 @@ public class ForwardAuthFilter implements GlobalFilter {
ServerWebExchange newExchange = exchange.mutate().request(newRequest).build(); ServerWebExchange newExchange = exchange.mutate().request(newRequest).build();
return chain.filter(newExchange); return chain.filter(newExchange);
} }
@Override
public int getOrder() {
return -100;
}
} }

Loading…
Cancel
Save