shreemaan-abhishek commented on code in PR #11987:
URL: https://github.com/apache/apisix/pull/11987#discussion_r1980647639


##########
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" }

Review Comment:
   Can we directly use a json string and return it instead of using a lua table 
and calling json.encode?



-- 
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]

Reply via email to