From 6f04d1a6b8c4b6f37991b032acdd56a8b009835e Mon Sep 17 00:00:00 2001 From: azilentech Date: Fri, 18 Mar 2022 18:06:10 +0530 Subject: [PATCH] introduced need_grant_token for composite conditions for better readability --- apisix/plugins/authz-keycloak.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apisix/plugins/authz-keycloak.lua b/apisix/plugins/authz-keycloak.lua index 88203b98b3555..0de03af1d8202 100644 --- a/apisix/plugins/authz-keycloak.lua +++ b/apisix/plugins/authz-keycloak.lua @@ -776,12 +776,13 @@ end function _M.access(conf, ctx) local headers = core.request.headers(ctx) - if conf.password_grant_token_generation_incoming_uri and - ngx.var.request_uri == - conf.password_grant_token_generation_incoming_uri and - headers["content-type"] == "application/x-www-form-urlencoded" and - core.request.get_method() == "POST" then - return generate_token_using_password_grant(conf,ctx) + local need_grant_token = conf.password_grant_token_generation_incoming_uri and + ngx.var.request_uri == + conf.password_grant_token_generation_incoming_uri and + headers["content-type"] == "application/x-www-form-urlencoded" and + core.request.get_method() == "POST" + if need_grant_token then + return generate_token_using_password_grant(conf,ctx) end log.debug("hit keycloak-auth access") local jwt_token, err = fetch_jwt_token(ctx)