Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add host config to solve the issuer not match problem when oidc server behind a revers proxy #175

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ You also need to set the `KONG_PLUGINS` environment variable
| `config.bearer_only` | no | false | Only introspect tokens without redirecting |
| `config.realm` | kong | false | Realm used in WWW-Authenticate response header |
| `config.logout_path` | /logout | false | Absolute path used to logout from the OIDC RP |
| `host` | no | false | host when request oidc server |

### Enabling

Expand Down
2 changes: 1 addition & 1 deletion kong-oidc-1.1.0-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ description = {
license = "Apache 2.0"
}
dependencies = {
"lua-resty-openidc ~> 1.6.1-1"
"lua-resty-openidc ~> 1.7.2-1"
}
build = {
type = "builtin",
Expand Down
3 changes: 2 additions & 1 deletion kong/plugins/oidc/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ return {
recovery_page_path = { type = "string" },
logout_path = { type = "string", required = false, default = '/logout' },
redirect_after_logout_uri = { type = "string", required = false, default = '/' },
filters = { type = "string" }
filters = { type = "string" },
host ={ type = "string", required = false}
}
}
13 changes: 12 additions & 1 deletion kong/plugins/oidc/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ function M.get_redirect_uri_path(ngx)
end

function M.get_options(config, ngx)
local function add_host(req)
local host= config.host
if host then
local h = req.headers or {}
h['host'] = host
req.headers = h
end
return req
end

return {
client_id = config.client_id,
client_secret = config.client_secret,
Expand All @@ -58,6 +68,7 @@ function M.get_options(config, ngx)
filters = parseFilters(config.filters),
logout_path = config.logout_path,
redirect_after_logout_uri = config.redirect_after_logout_uri,
http_request_decorator= add_host,
}
end

Expand Down Expand Up @@ -96,4 +107,4 @@ function M.has_bearer_access_token()
return false
end

return M
return M