bzp2010 commented on code in PR #11987:
URL: https://github.com/apache/apisix/pull/11987#discussion_r1966678412
##########
apisix/plugins/openid-connect.lua:
##########
@@ -547,6 +575,40 @@ function _M.rewrite(plugin_conf, ctx)
return 403, core.json.encode(error_response)
end
end
+
+ -- jwt audience claim validator
+ local audience_claim = core.table.try_read_attr(conf,
"claim_validator",
+ "audience",
"claim") or "aud"
+ local audience_value = response[audience_claim]
+ if core.table.try_read_attr(conf, "claim_validator", "audience",
"required")
+ and not audience_value then
+ core.log.error("OIDC introspection failed: required audience
(",
+ audience_claim, ") not present")
+ local error_response = { error = "required audience claim not
present" }
+ return 403, core.json.encode(error_response)
+ end
+ if core.table.try_read_attr(conf, "claim_validator", "audience",
"match_with_client_id")
+ and audience_value ~= nil then
+ local error_response = { error = "mismatched audience" }
+ local matched = false
+ if type(audience_value) == "table" then
+ for _, v in ipairs(audience_value) do
+ if conf.client_id == v then
+ matched = true
+ end
+ end
+ if not matched then
+ core.log.error("OIDC introspection failed: ",
+ "audience list does not contain the
client id")
+ return 403, core.json.encode(error_response)
+ end
+ elseif conf.client_id ~= audience_value then
+ core.log.error("OIDC introspection failed: ",
Review Comment:
Makes sense, but the rest of the code uses error, so I'm choosing to follow
the precedent, should we break that "convention"?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]