[GitHub] [apisix] bzp2010 commented on a change in pull request #5779: feat: supprot OPA plugin complex response
bzp2010 commented on a change in pull request #5779: URL: https://github.com/apache/apisix/pull/5779#discussion_r769291451 ## File path: apisix/plugins/opa.lua ## @@ -89,13 +90,31 @@ function _M.access(conf, ctx) -- parse the results of the decision local data, err = core.json.decode(res.body) -if err then +if err or not data or not data.result then core.log.error("invalid response body: ", res.body, " err: ", err) Review comment: splited to "invalid response body" and "invalid OPA decision format" -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] bzp2010 commented on a change in pull request #5779: feat: supprot OPA plugin complex response
bzp2010 commented on a change in pull request #5779: URL: https://github.com/apache/apisix/pull/5779#discussion_r769291451 ## File path: apisix/plugins/opa.lua ## @@ -89,13 +90,31 @@ function _M.access(conf, ctx) -- parse the results of the decision local data, err = core.json.decode(res.body) -if err then +if err or not data or not data.result then core.log.error("invalid response body: ", res.body, " err: ", err) Review comment: splited to "invalid response body" and "invalid OPA decision format" -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] bzp2010 commented on a change in pull request #5779: feat: supprot OPA plugin complex response
bzp2010 commented on a change in pull request #5779: URL: https://github.com/apache/apisix/pull/5779#discussion_r769291451 ## File path: apisix/plugins/opa.lua ## @@ -89,13 +90,31 @@ function _M.access(conf, ctx) -- parse the results of the decision local data, err = core.json.decode(res.body) -if err then +if err or not data or not data.result then core.log.error("invalid response body: ", res.body, " err: ", err) Review comment: splited -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] bzp2010 commented on a change in pull request #5779: feat: supprot OPA plugin complex response
bzp2010 commented on a change in pull request #5779: URL: https://github.com/apache/apisix/pull/5779#discussion_r769272000 ## File path: apisix/plugins/opa.lua ## @@ -89,13 +90,31 @@ function _M.access(conf, ctx) -- parse the results of the decision local data, err = core.json.decode(res.body) -if err then +if err or not data or not data.result then core.log.error("invalid response body: ", res.body, " err: ", err) Review comment: I split it into an "invalid response body", and "invalid OPA decision format: xxx err: `result` field does not exist". -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] bzp2010 commented on a change in pull request #5779: feat: supprot OPA plugin complex response
bzp2010 commented on a change in pull request #5779: URL: https://github.com/apache/apisix/pull/5779#discussion_r768621872 ## File path: apisix/plugins/opa.lua ## @@ -94,8 +95,27 @@ function _M.access(conf, ctx) return 503 end -if not data.result then -return 403 +local result = data.result Review comment: Yes, it does have problems, I modified the error checking logic so that when this happens, it responds with 503 and take a log. -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] bzp2010 commented on a change in pull request #5779: feat: supprot OPA plugin complex response
bzp2010 commented on a change in pull request #5779: URL: https://github.com/apache/apisix/pull/5779#discussion_r768618008 ## File path: apisix/plugins/opa.lua ## @@ -94,8 +95,27 @@ function _M.access(conf, ctx) return 503 end -if not data.result then -return 403 +local result = data.result + +if not result.allow then +if result.headers then +core.response.set_header(result.headers) +end + +local status_code = 403 +local reason = "" Review comment: Got it, I agree with it. changed -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] bzp2010 commented on a change in pull request #5779: feat: supprot OPA plugin complex response
bzp2010 commented on a change in pull request #5779: URL: https://github.com/apache/apisix/pull/5779#discussion_r768453548 ## File path: apisix/plugins/opa.lua ## @@ -94,8 +95,27 @@ function _M.access(conf, ctx) return 503 end -if not data.result then -return 403 +local result = data.result + +if not result.allow then +if result.headers then +core.response.set_header(result.headers) Review comment: added -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] bzp2010 commented on a change in pull request #5779: feat: supprot OPA plugin complex response
bzp2010 commented on a change in pull request #5779: URL: https://github.com/apache/apisix/pull/5779#discussion_r768453393 ## File path: apisix/plugins/opa.lua ## @@ -94,8 +95,27 @@ function _M.access(conf, ctx) return 503 end -if not data.result then -return 403 +local result = data.result + +if not result.allow then +if result.headers then +core.response.set_header(result.headers) +end + +local status_code = 403 +local reason = "" + +if result.status_code then +status_code = result.status_code +end + +if result.reason then +reason = type(result.reason) == "table" Review comment: added -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org