Skip to content

Commit

Permalink
v0.0.4-2 - Fix fault_tolerant when opa is down or policy is missing, …
Browse files Browse the repository at this point in the history
…X-Kong-Authz-Skipped also on request
  • Loading branch information
carnei-ro committed Nov 11, 2020
1 parent 737bbe4 commit 667cfa5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ Custom Kong plugin to allow for fine grained Authorization through [Open Policy

Plugin will continue the request to the upstream target if OPA responds with `true`, else the plugin will return a `403 Forbidden`.

Plugin will add the response headers:
Plugin will add the:

- `X-Kong-Authz-Latency`: Latency generated by the plugin
- `X-Kong-Authz-Cache`: "Miss" or "Hit" when cache is enabled
- `X-Kong-Authz-Skip`: "true" when `fault_tolerant` is enabled and Kong had troubles
- request headers:
- `X-Kong-Authz-Skipped`: "true" when `fault_tolerant` is enabled and Kong had troubles

- response headers:
- `X-Kong-Authz-Latency`: Latency generated by the plugin
- `X-Kong-Authz-Cache`: "Miss" or "Hit" when cache is enabled
- `X-Kong-Authz-Skipped`: "true" when `fault_tolerant` is enabled and Kong had troubles

Plugin priority: `799`

Expand Down
3 changes: 2 additions & 1 deletion opa/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ function _M.execute(conf)
if (not body) or (err) then
if conf.fault_tolerant then
kong.response.set_header("X-Kong-Authz-Latency", (ngx.now() - start_time))
kong.response.set_header("X-Kong-Authz-Skip", "true")
kong.response.set_header("X-Kong-Authz-Skipped", "true")
kong.service.request.set_header("X-Kong-Authz-Skipped", "true")
return true
else
return kong.response.exit(500, { message = "An unexpected error occurred", error = err })
Expand Down

0 comments on commit 667cfa5

Please sign in to comment.