From ba0bb5ef6688afbf5c014b013b744f7ab6800013 Mon Sep 17 00:00:00 2001 From: wklken Date: Mon, 27 Nov 2023 14:41:07 +0800 Subject: [PATCH] fix(bk-auth-verify): move into the bk_secret not empty section --- .../bk-auth-verify/app-account-verifier.lua | 16 ++++++++-------- .../bk-auth-verify/test-app-account-verifier.lua | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/apisix/plugins/bk-auth-verify/app-account-verifier.lua b/src/apisix/plugins/bk-auth-verify/app-account-verifier.lua index b7882c8..7780eae 100644 --- a/src/apisix/plugins/bk-auth-verify/app-account-verifier.lua +++ b/src/apisix/plugins/bk-auth-verify/app-account-verifier.lua @@ -46,15 +46,15 @@ function _M.verify_app(self) return bk_app_define.new_anonymous_app("app code cannot be empty") end - -- check the length before call bkauth apis - if string.len(self.app_code) > 32 then - return bk_app_define.new_anonymous_app("app code cannot be longer than 32 characters") - end - if string.len(self.app_secret) > 128 then - return bk_app_define.new_anonymous_app("app secret cannot be longer than 128 characters") - end - if not pl_types.is_empty(self.app_secret) then + -- check the length before call bkauth apis + if string.len(self.app_code) > 32 then + return bk_app_define.new_anonymous_app("app code cannot be longer than 32 characters") + end + if string.len(self.app_secret) > 128 then + return bk_app_define.new_anonymous_app("app secret cannot be longer than 128 characters") + end + return self:verify_by_app_secret() end diff --git a/src/apisix/tests/bk-auth-verify/test-app-account-verifier.lua b/src/apisix/tests/bk-auth-verify/test-app-account-verifier.lua index ce56f34..069210c 100644 --- a/src/apisix/tests/bk-auth-verify/test-app-account-verifier.lua +++ b/src/apisix/tests/bk-auth-verify/test-app-account-verifier.lua @@ -87,6 +87,7 @@ describe( "app_code length is greather 32", function() local auth_params = auth_params_mod.new({ bk_app_code = "123456789012345678901234567890123", + bk_app_secret = "world", }) local verifier = app_account_verifier_mod.new(auth_params)