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

X-Forwarded Headers Missing in Token Endpoint Call #532

Open
vinay-moldireddy opened this issue Feb 12, 2025 · 1 comment
Open

X-Forwarded Headers Missing in Token Endpoint Call #532

vinay-moldireddy opened this issue Feb 12, 2025 · 1 comment

Comments

@vinay-moldireddy
Copy link

vinay-moldireddy commented Feb 12, 2025

Description:

Keycloak 23 requires X-Forwarded headers to validate the iss (issuer) of the refresh token during a REFRESH_TOKEN request. However, the openidc.lua implementation in Kong does not include the following headers when making the refresh token request:

X-Forwarded-Host
X-Forwarded-Port
X-Forwarded-Proto
This omission causes issues with token validation, as Keycloak expects these headers to properly resolve the issuer.

We start to see this issue because keycloak fixed a bug- keycloak/keycloak#22191

Expected Behavior:

Kong should include the necessary X-Forwarded headers in the refresh token request to ensure compatibility with Keycloak 23.

Steps to Reproduce:

Set up Keycloak 23 as an identity provider.
Configure Kong with OpenID Connect and enable token refresh.
Attempt to refresh a token using Kong’s OIDC plugin.
Observe that Keycloak rejects the request due to incorrect iss validation.

Suggested Fix:

Modify openidc.lua to include X-Forwarded-Host, X-Forwarded-Port, and X-Forwarded-Proto in the refresh token request headers.

@oldium
Copy link
Collaborator

oldium commented Feb 12, 2025

X-Forwarded-* headers are added by proxies, the headers should not be part of the originating request (like the one made by openidc.lua). Your description suggests that the openidc.lua tries to refresh the token on a URL host that differs from the original issuer host. So the possible issues could be:

  1. Your openidc configuration contains discovery URL host, which does not match the issuer host (iss claim).
  2. The token endpoint URL host from the discovery address document does not match the issuer host.
  3. You are using discovery as object and your discovery.token_endpoint contains URL host, which does not match the issuer host.

So please check the configuration - if the URL hosts are consistent and always match the issuer host.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants