diff --git a/kong/plugins/basic-auth/access.lua b/kong/plugins/basic-auth/access.lua index ed124f5eaedb..32e2729b3207 100644 --- a/kong/plugins/basic-auth/access.lua +++ b/kong/plugins/basic-auth/access.lua @@ -158,7 +158,7 @@ function _M.execute(conf) local ok, err = do_authentication(conf) if not ok then - if conf.anonymous ~= "" then + if conf.anonymous ~= "" and conf.anonymous ~= nil then -- get anonymous user local consumer, err = cache.get_or_set(cache.consumer_key(conf.anonymous), nil, load_consumer_into_memory, conf.anonymous, true) diff --git a/kong/plugins/hmac-auth/access.lua b/kong/plugins/hmac-auth/access.lua index 10b6fc14ea00..346170229317 100644 --- a/kong/plugins/hmac-auth/access.lua +++ b/kong/plugins/hmac-auth/access.lua @@ -210,7 +210,7 @@ function _M.execute(conf) local ok, err = do_authentication(conf) if not ok then - if conf.anonymous ~= "" then + if conf.anonymous ~= "" and conf.anonymous ~= nil then -- get anonymous user local consumer, err = cache.get_or_set(cache.consumer_key(conf.anonymous), nil, load_consumer_into_memory, conf.anonymous, true) diff --git a/kong/plugins/jwt/handler.lua b/kong/plugins/jwt/handler.lua index a4be97ecac6a..e0cc77f05726 100644 --- a/kong/plugins/jwt/handler.lua +++ b/kong/plugins/jwt/handler.lua @@ -180,7 +180,7 @@ function JwtHandler:access(conf) local ok, err = do_authentication(conf) if not ok then - if conf.anonymous ~= "" then + if conf.anonymous ~= "" and conf.anonymous ~= nil then -- get anonymous user local consumer, err = cache.get_or_set(cache.consumer_key(conf.anonymous), nil, load_consumer, conf.anonymous, true) diff --git a/kong/plugins/key-auth/handler.lua b/kong/plugins/key-auth/handler.lua index 79d0dcd6d1cb..56391c6491db 100644 --- a/kong/plugins/key-auth/handler.lua +++ b/kong/plugins/key-auth/handler.lua @@ -157,7 +157,7 @@ function KeyAuthHandler:access(conf) local ok, err = do_authentication(conf) if not ok then - if conf.anonymous ~= "" then + if conf.anonymous ~= "" and conf.anonymous ~= nil then -- get anonymous user local consumer, err = cache.get_or_set(cache.consumer_key(conf.anonymous), nil, load_consumer, conf.anonymous, true) diff --git a/kong/plugins/ldap-auth/access.lua b/kong/plugins/ldap-auth/access.lua index 5956c581483a..48d46a86bafb 100644 --- a/kong/plugins/ldap-auth/access.lua +++ b/kong/plugins/ldap-auth/access.lua @@ -167,7 +167,7 @@ function _M.execute(conf) local ok, err = do_authentication(conf) if not ok then - if conf.anonymous ~= "" then + if conf.anonymous ~= "" and conf.anonymous ~= nil then -- get anonymous user local consumer, err = cache.get_or_set(cache.consumer_key(conf.anonymous), nil, load_consumer, conf.anonymous, true) diff --git a/kong/plugins/oauth2/access.lua b/kong/plugins/oauth2/access.lua index 746fd56e26b6..ccfcfee9bb10 100644 --- a/kong/plugins/oauth2/access.lua +++ b/kong/plugins/oauth2/access.lua @@ -560,7 +560,7 @@ function _M.execute(conf) local ok, err = do_authentication(conf) if not ok then - if conf.anonymous ~= "" then + if conf.anonymous ~= "" and conf.anonymous ~= nil then -- get anonymous user local consumer, err = cache.get_or_set(cache.consumer_key(conf.anonymous), nil, load_consumer_into_memory, conf.anonymous, true)