From c1d1c8db9d703fabaf4eb1af9426587fc6769841 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apisix/plugins/authz-keycloak.lua b/apisix/plugins/authz-keycloak.lua index 88203b98b355..a117f5cda9d7 100644 --- a/apisix/plugins/authz-keycloak.lua +++ b/apisix/plugins/authz-keycloak.lua @@ -776,12 +776,12 @@ 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 + 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" then - return generate_token_using_password_grant(conf,ctx) + 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)