Przeglądaj źródła

此处修改曾导致 nacos修改xss开关时,spring容器未重启,filter仍起效。故增加参数判断,参数刷新后,xss开关正常关闭。
此处修改曾导致 nacos修改xss开关时,spring容器未重启,filter仍起效。故增加参数判断,参数刷新后,xss开关正常关闭。

Signed-off-by: ylwang <ylwang@makwing.com>

ylwang 3 lat temu
rodzic
commit
bc1c1dbfa7

+ 4 - 0
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/XssFilter.java

@@ -42,6 +42,10 @@ public class XssFilter implements GlobalFilter, Ordered
42
     public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
42
     public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
43
     {
43
     {
44
         ServerHttpRequest request = exchange.getRequest();
44
         ServerHttpRequest request = exchange.getRequest();
45
+        // xss开关未开启 或 通过nacos关闭,不过滤
46
+        if(!xss.getEnabled()){
47
+            return chain.filter(exchange);
48
+        }
45
         // GET DELETE 不过滤
49
         // GET DELETE 不过滤
46
         HttpMethod method = request.getMethod();
50
         HttpMethod method = request.getMethod();
47
         if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE)
51
         if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE)