diff --git a/cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/config/WhitIPConfig.java b/cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/config/WhitIPConfig.java index 2dcf10386cb5ee84c34af4f871657510c92f9040..d580df23b35999852fab69d40ed14d602ddd8bac 100644 --- a/cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/config/WhitIPConfig.java +++ b/cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/config/WhitIPConfig.java @@ -20,5 +20,6 @@ import java.util.List; @ConditionalOnExpression("!'${whiteip}'.isEmpty()") @ConfigurationProperties(prefix = "whiteip") public class WhitIPConfig { + private Boolean limitFlag; private List whites = new ArrayList<>(); } diff --git a/cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/filter/RequestGlobalFilter.java b/cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/filter/RequestGlobalFilter.java index 6cf236a482f87d54f0348c2b5d2922df7b228160..ca5e2126b0cdac4b48aae422e0e7cff68322b198 100644 --- a/cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/filter/RequestGlobalFilter.java +++ b/cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/filter/RequestGlobalFilter.java @@ -67,7 +67,7 @@ public class RequestGlobalFilter implements GlobalFilter, Ordered { String ip = WebUtils.getIP(request); log.error("RemoteAddress ===================> {}", request.getRemoteAddress()); try { - if (!IPStrUtil.matches(ip, whitIPConfig.getWhites())) { + if (whitIPConfig.getLimitFlag() && !IPStrUtil.matches(ip, whitIPConfig.getWhites())) { ServerHttpResponse response = exchange.getResponse(); response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED); response.getHeaders().set("Content-type", "application/json; charset=utf-8");