Skip to content

Commit

Permalink
kong_api_authz: Fix error when no JWT token is provided
Browse files Browse the repository at this point in the history
When no token is provided with the request, the execution fail the attempt to index the field 'payload' (a nil value).
In case the subject from the JWT token is not be defined or there's no token, 'anonymous' will be used instead.

Fixes open-policy-agent#146
  • Loading branch information
zahiyo committed Jun 23, 2021
1 parent a010b71 commit 96bbc1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kong_api_authz/src/kong/plugins/opa/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function _M.execute(conf)
kong.log.debug(interp("Access allowed to ${method} ${path} for user ${subject}", {
method = input.method,
path = input.path,
subject = token.payload.sub
subject = (token.payload and token.payload.sub or 'anonymous')
}))
end

Expand Down

0 comments on commit 96bbc1b

Please sign in to comment.