Skip to content
12 changes: 12 additions & 0 deletions apisix/plugins/openid-connect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ local schema = {
type = "boolean",
default = true
},
set_id_token_original_header = {
description = "Whether the ID token should be added in the X-ID-Token-Original header to " ..
"the request for downstream.",
type = "boolean",
default = true
},
set_userinfo_header = {
description = "Whether the user info token should be added in the X-Userinfo " ..
"header to the request for downstream.",
Expand Down Expand Up @@ -696,6 +702,12 @@ function _M.rewrite(plugin_conf, ctx)
core.request.set_header(ctx, "X-ID-Token", ngx.encode_base64(token))
end

-- Add X-ID-Token-Original header, maybe.
if session and session.data and session.data.enc_id_token and conf.set_id_token_original_header then
local token = session.data.enc_id_token
core.request.set_header(ctx, "X-ID-Token-Original", token)
end

-- Add X-Userinfo header, maybe.
if response.user and conf.set_userinfo_header then
core.request.set_header(ctx, "X-Userinfo",
Expand Down
Loading
Loading