From 79b40378ea5162afbff7a3742d32b71bba4c7c20 Mon Sep 17 00:00:00 2001 From: Jeffy Mathew Date: Fri, 10 Jan 2025 13:08:29 +0100 Subject: [PATCH] Make IPAccessControlDisabled precede over EnableIpWhiteListing and EnableIpBlackListing --- gateway/mw_ip_blacklist.go | 4 ++-- gateway/mw_ip_whitelist.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/mw_ip_blacklist.go b/gateway/mw_ip_blacklist.go index c974c3e3cd4..1c236fc167a 100644 --- a/gateway/mw_ip_blacklist.go +++ b/gateway/mw_ip_blacklist.go @@ -18,11 +18,11 @@ func (i *IPBlackListMiddleware) Name() string { } func (i *IPBlackListMiddleware) EnabledForSpec() bool { - if i.Spec.APIDefinition.IPAccessControlDisabled { + if !(!i.Spec.APIDefinition.IPAccessControlDisabled || i.Spec.APIDefinition.EnableIpBlacklisting) { return false } - return i.Spec.EnableIpBlacklisting && len(i.Spec.BlacklistedIPs) > 0 + return len(i.Spec.APIDefinition.BlacklistedIPs) > 0 } // ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail diff --git a/gateway/mw_ip_whitelist.go b/gateway/mw_ip_whitelist.go index 10be87961d7..82aaf00346a 100644 --- a/gateway/mw_ip_whitelist.go +++ b/gateway/mw_ip_whitelist.go @@ -18,11 +18,11 @@ func (i *IPWhiteListMiddleware) Name() string { } func (i *IPWhiteListMiddleware) EnabledForSpec() bool { - if i.Spec.APIDefinition.IPAccessControlDisabled { + if !(!i.Spec.APIDefinition.IPAccessControlDisabled || i.Spec.APIDefinition.EnableIpWhiteListing) { return false } - return i.Spec.APIDefinition.EnableIpWhiteListing && len(i.Spec.APIDefinition.AllowedIPs) > 0 + return len(i.Spec.APIDefinition.AllowedIPs) > 0 } // ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail