Skip to content

Commit

Permalink
Merge pull request #130 from holaplex/mpw/gw-json-unauthorized-error
Browse files Browse the repository at this point in the history
send 403 errors in json format and attach request_id to it
  • Loading branch information
mpwsh authored Jul 28, 2023
2 parents 58de147 + 2976d7b commit b4042b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/hub-gateway/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.23.5
version: 0.23.6

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
14 changes: 6 additions & 8 deletions charts/hub-gateway/plugins/authz.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ local core = require("apisix.core")
local http = require("resty.http")
local helper = require("apisix.plugins.authz.helper")
local json = require("apisix.core.json")
local type = type


local schema = {
type = "object",
Expand Down Expand Up @@ -123,12 +121,12 @@ function _M.access(conf, ctx)
status_code = result.status_code
end

local reason = nil
if result.reason then
reason = type(result.reason) == "table"
and json.encode(result.reason)
or result.reason
end
local req_id = core.request.header(ctx, "X-Request-Id")
local reason = json.encode({
code = status_code,
message = "Unauthorized",
request_id = req_id
})

return status_code, reason
end
Expand Down

0 comments on commit b4042b0

Please sign in to comment.