Skip to content

fix: strip http forwarded headers from requests to kc#624

Merged
manusa merged 1 commit intocontainers:mainfrom
Cali0707:fix-keycloak-middleware
Jan 7, 2026
Merged

fix: strip http forwarded headers from requests to kc#624
manusa merged 1 commit intocontainers:mainfrom
Cali0707:fix-keycloak-middleware

Conversation

@Cali0707
Copy link
Collaborator

@Cali0707 Cali0707 commented Jan 7, 2026

While testing the server deployed in an openshift cluster, the wellknown proxy to keycloak was not working correctly, as all the various forwarded headers led keycloak to set the base url to the url to the MCP server, not the keycloak server.

This PR just strips those forwarded headers before passing requests to the keycloak server.

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707 Cali0707 requested review from manusa and matzew January 7, 2026 14:59
Copy link
Collaborator

@matzew matzew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

thanks for picking this here!

@manusa
Copy link
Member

manusa commented Jan 7, 2026

I need to properly check this. I recall that the header forwarding was added precisely for a proxy-related issue.
Do you have some environment to try or a way to reproduce the issue?

@Cali0707
Copy link
Collaborator Author

Cali0707 commented Jan 7, 2026

Do you have some environment to try or a way to reproduce the issue?

To reproduce, you can install keycloak + the MCP server in a OpenShift cluster (behind routes), and then try to authenticate

I was using the make targets in openshift#80

@manusa
Copy link
Member

manusa commented Jan 7, 2026

To reproduce, you can install keycloak + the MCP server in a OpenShift cluster (behind routes), and then try to authenticate

OK, I've checked the history.
This was added for the MCP inspector and the CORS issue #406

Was not present in the early implementation when everything was tested with the OpenShift setup.

I assume that the problem is that the URLs from the Well Known document now point to the MCP URL instead of that of the exposed Keycloak endpoints.

@Cali0707
Copy link
Collaborator Author

Cali0707 commented Jan 7, 2026

I assume that the problem is that the URLs from the Well Known document now point to the MCP URL instead of that of the exposed Keycloak endpoints.

Yes, that is exactly the issue this is trying to resolve

Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is needed for downstream work, I think we can merge safely.
As agreed internally we may follow up to provide only headers necessary for the MCP inspector

@manusa manusa added this to the 0.1.0 milestone Jan 7, 2026
@manusa manusa merged commit 166aa63 into containers:main Jan 7, 2026
6 checks passed
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

Successfully merging this pull request may close these issues.

3 participants