whitelist - fix missing check for empty server_name in multisite mode

This commit is contained in:
florian 2024-02-27 21:48:10 +01:00
parent ab949bf710
commit 252c16b763
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500

View file

@ -15,7 +15,6 @@ set_by_lua_block $whitelist_default {
local datastore = cdatastore:new()
local logger = clogger:new("WHITELIST-DEFAULT")
local checks = {
["IP"] = "ip" .. ngx_var.remote_addr,
}
@ -60,14 +59,16 @@ set_by_lua_block $whitelist_default {
for server_name, server_vars in pairs(variables) do
local domains = server_vars["SERVER_NAME"]
local domain = domains:gmatch("%S+")()
for k, v in pairs(checks) do
local ok, data = cachestore:get("plugin_whitelist_" .. domain .. v)
if not ok and data then
logger:log(ERR, "error while checking cachestore : " .. data)
elseif ok and data ~= nil and data ~= "ok" then
logger:log(NOTICE, "whitelisting on default server (original server = " .. domain .. " and data = " .. data .. ")")
ngx_var.is_whitelisted = "yes"
return "ok"
if domain then
for k, v in pairs(checks) do
local ok, data = cachestore:get("plugin_whitelist_" .. domain .. v)
if not ok and data then
logger:log(ERR, "error while checking cachestore : " .. data)
elseif ok and data ~= nil and data ~= "ok" then
logger:log(NOTICE, "whitelisting on default server (original server = " .. domain .. " and data = " .. data .. ")")
ngx_var.is_whitelisted = "yes"
return "ok"
end
end
end
end