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