From bb88a8071c8a30caed72b620f60835cc238c13f9 Mon Sep 17 00:00:00 2001 From: thefosk Date: Tue, 9 May 2017 11:05:34 -0700 Subject: [PATCH] hotfix(auth) handle nil anonymous consumers --- kong/plugins/basic-auth/access.lua | 2 +- kong/plugins/hmac-auth/access.lua | 2 +- kong/plugins/jwt/handler.lua | 2 +- kong/plugins/key-auth/handler.lua | 2 +- kong/plugins/ldap-auth/access.lua | 2 +- kong/plugins/oauth2/access.lua | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) 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)