Skip to content

Commit

Permalink
introduced need_grant_token for composite conditions for better reada…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
azilentech committed Mar 18, 2022
1 parent 8f34241 commit 6f04d1a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apisix/plugins/authz-keycloak.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6f04d1a

Please sign in to comment.