Skip to content

Commit

Permalink
Merge pull request #2 from cloudbeds/feat/is-2628-more-debugging
Browse files Browse the repository at this point in the history
Feat/is 2628 more debugging
  • Loading branch information
mykyta-batalov authored Jul 25, 2024
2 parents 1b67d1a + 82b8670 commit 292aab5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package = "kong-plugin-oidc"
version = "1.4.0-1"
version = "1.4.0-2"
source = {
url = "git://github.com/revomatico/kong-oidc",
tag = "master",
Expand All @@ -22,7 +22,8 @@ description = {
license = "Apache 2.0"
}
dependencies = {
"lua-resty-openidc ~> 1.7.6-3"
"lua-resty-openidc ~> 1.7.6-3",
"cjson ~> 2.1.0.10-1"
}
build = {
type = "builtin",
Expand Down
2 changes: 2 additions & 0 deletions kong/plugins/oidc/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local OidcHandler = {
local utils = require("kong.plugins.oidc.utils")
local filter = require("kong.plugins.oidc.filter")
local session = require("kong.plugins.oidc.session")
local cjson = require("cjson")


function OidcHandler:access(config)
Expand Down Expand Up @@ -117,6 +118,7 @@ function introspect(oidcConfig)
res, err = require("resty.openidc").introspect(oidcConfig)
end
if err then
ngx.log(ngx.DEBUG, "oidc error: " .. cjson.encode(err) .. cjson.encode(res) .. cjson.encode(utils.sanitize_oidc_config(oidcConfig)))
if oidcConfig.bearer_only == "yes" then
ngx.header["WWW-Authenticate"] = 'Bearer realm="' .. oidcConfig.realm .. '",error="' .. err .. '"'
return kong.response.error(ngx.HTTP_UNAUTHORIZED)
Expand Down
13 changes: 13 additions & 0 deletions kong/plugins/oidc/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,17 @@ function M.has_common_item(t1, t2)
return false
end

-- sanitize oidc config for debugging output
function M.sanitize_oidc_config(config)
local sanitized = {}
for k, v in pairs(config) do
if k == "client_id" or k == "client_secret" then
sanitized[k] = "<hidden>"
else
sanitized[k] = v
end
end
return sanitized
end

return M

0 comments on commit 292aab5

Please sign in to comment.