Repository navigation
proxyrunner support for contacting oauth server through https_proxy #6745
Description
Activity
- addedneeds-triageIssue needs initial triage by a maintainerIssue needs initial triage by a maintainer
on Oct 2, 2026 - changed the title
[-]proxyrunner support for contacting oidc server through https_proxy[/-][+]proxyrunner support for contacting oauth server through https_proxy[/+]on Oct 2, 2026 @gberche-orange Thanks for the detailed report. I reviewed #6670 with this case in mind: #6670 (review)
Incoming token validation uses the same
HttpClientBuilderand injects its client into the JWKS cache (pkg/auth/token.go:671-684). So the current patch also addresses the missing proxy selection on this path, even without the embedded auth server.It is not yet a confirmed complete fix for this deployment. #6670 remains under review, including its proxy/private-IP policy. If revised to explicit opt-in, incoming JWKS/discovery must be included alongside upstream OAuth/DCR.
Could you confirm, without sharing credentials or internal hostnames:
- Does the proxy hostname resolve to a private address?
- Does the proxy itself expect TLS for the configured
https://myproxy:3128URL? - Is
spec.inline.jwksAllowPrivateIPconfigured, or left at its default?
The current default dial policy still rejects private proxy addresses. Enabling
jwksAllowPrivateIPalso permits private OIDC destinations, so it is not a narrowly scoped proxy permission or a general workaround. These details will help distinguish the proxy-selection fix from any remaining connectivity/TLS problem. The reporter's Kubernetes deployment has not yet been reproduced.Thanks @Sanskarzz for your prompt response, and inclusion of my use-case in your review at #6670 (review)
Here are my details about my use-case:
The JWKS endpoint (from keycloak) is not reachable directly due to network ACL, and use of the explicit HTTP proxy (HTTP CONNECT) is required to reach it.
Does the proxy hostname resolve to a private address?
Yes, the proxy hostname resolves to a IP private address within the documented range at
https://en.wikipedia.org/wiki/Private_network#Private_IPv4_addressesDoes the proxy itself expect TLS for the configured https://myproxy:3128 URL?
For this specific use-case, the proxy does not enforce use of TLS. I've fixed in the original report ashttps_proxy=http://myproxy:3128. In some other cases, HTTP proxy expects TLS, so support for this would also be useful in 2nd step (potentially requiring self signed ca certs injection as well)Is spec.inline.jwksAllowPrivateIP configured, or left at its default?
It is left as default (falsefrom https://docs.stacklok.com/toolhive/reference/crds/mcpoidcconfig#specinline)The current default dial policy still rejects private proxy addresses. Enabling jwksAllowPrivateIP also permits private OIDC destinations
Thanks, I'll enable this field. Would it make sense to document in https://docs.stacklok.com/toolhive/reference/crds/mcpoidcconfig#specinline that this properyy also applies to tcp connection to http proxy configured from environment variable http_proxy? It isn't obvious to me from reading current doc
jwksAllowPrivateIP boolean JWKSAllowPrivateIP allows JWKS/OIDC endpoints on private IP addresses. Note: at runtime, if either JWKSAllowPrivateIP or ProtectedResourceAllowPrivateIP is true, private IPs are allowed for all OIDC HTTP requests (JWKS, discovery, introspection).default false protectedResourceAllowPrivateIP boolean ProtectedResourceAllowPrivateIP allows protected resource endpoint on private IP addresses. Note: at runtime, if either ProtectedResourceAllowPrivateIP or JWKSAllowPrivateIP is true, private IPs are allowed for all OIDC HTTP requests (JWKS, discovery, introspection).default false Thanks @gberche-orange, this clarifies the setup.
https_proxy=http://myproxy:3128is appropriate for accessing an HTTPS JWKS endpoint through a plain HTTP proxy using CONNECT; the JWKS connection remains HTTPS.One clarification: enabling
jwksAllowPrivateIPalone will not resolve this on v0.51.2, because that client still ignores the proxy environment variables. Proxy selection also needs the fix in #6670 or its revised implementation. With the current patch, the private-IP policy would then affect whether the proxy connection is permitted.Your documentation suggestion makes sense. We should explain that interaction once the proxy policy is settled, including that
jwksAllowPrivateIPpermits private OIDC destinations too—it is broader than permission to reach only the proxy.We should keep #6745 open until the supported configuration successfully fetches JWKS in your deployment.
thanks @Sanskarzz for the clarification.
One additional user feedback/requirement related to operability: in order to be able to quickly diagnose that connection is rejected due to private ip filtering, user would expect a clear error log clarifying the rejected http proxy dial in.
Reacted by Sanskar Gurdasani
This is similar to #6671 but for a use-case not enabling toolhive internal oauth proxy: the proxy runner failing to validate incoming oauth bearer token in the /initialize endpoint (following successfull DRC and Oauth token by the mcp client) due to not honoring the injected https_proxy/no_proxy environment variables
Here is my redacted configuration fragment
Observed symptom:
Fast (142ms) 401 response on mcp
initializerequest with response header:www-authenticate Bearer realm="https://redacted-upstream-oidc-host/service-manager-realm", resource_metadata="https://postgres-mcp-redacted-host/.well-known/oauth-protected-resource/mcp", error="invalid_token", error_description="failed to parse token: token is unverifiable: error while executing keyfunc: failed to lookup JWKS: resource \"https://redacted-upstream-oidc-host/realms/service-manager-realm/protocol/openid-connect/certs\" is not ready"The
https_proxyand theno_proxyenv variables are properly injected into proxy-runner pod (through support contributed in #983)However, the proxy runner still fails to reach the upstream OIDC server, unfortunately without friendly traces
{"time":"2026-10-02T09:45:21Z","level":"DEBUG","msg":"JWKS URL registered but first fetch not ready; fetching continues in background","jwks_url":"https://redacted-upstream-oidc-host/realms/service-manager-realm/protocol/openid-connect/certs","error":"failed to add resource: resource registered but not ready: context deadline exceeded"}Associated code path
https://github.com/jwx-go/jwkfetch/blob/7e8d989175276661062d594a2bd372c0a3439dee/cache.go#L134-L151
Same analysis over httpclient creation than the one from @schonmann in #6671