Skip to content

Fix OpenAI webproxy auth with Apache HttpClient 5 - #1070

Open
ehoogerbeets wants to merge 7 commits into
box:upstream-patchedfrom
ehoogerbeets:fixProxyBearerToken2
Open

Fix OpenAI webproxy auth with Apache HttpClient 5#1070
ehoogerbeets wants to merge 7 commits into
box:upstream-patchedfrom
ehoogerbeets:fixProxyBearerToken2

Conversation

@ehoogerbeets

@ehoogerbeets ehoogerbeets commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Switch OpenAI HTTP clients from JDK java.net.http.HttpClient to Apache HttpClient 5 (already used elsewhere in Mojito) so proxy auth negotiation and the OpenAI Authorization: Bearer header work correctly (avoids JDK-8326949 / silent hangs through webproxy).
  • Keep connect timeouts so unreachable proxies fail quickly instead of hanging, and restore/enable Basic tunneling for HTTPS CONNECT where needed.
  • Add optional proxy-preferred-auth-schemes configuration so deployments can override HttpClient’s default auth scheme preference when a proxy advertises schemes it does not actually support (e.g. Digest before Basic).
  • Add OpenAIClientIntegrationTest (opt-in via configured OpenAI properties) as a smoke test for end-to-end ChatGPT connectivity, including webproxy support.
  • Document the new proxy auth scheme settings in the Spring Boot configuration docs.

Context

Follow-up to #1069 (fixProxyBearerToken), incorporating review feedback and the preferred-auth-schemes enhancement on branch fixProxyBearerToken2.

Test plan

  • Unit tests pass for OpenAIHttpClientFactory, OpenAIClient, and AI translate/review config property wiring
  • With OpenAI + webproxy configured locally, run OpenAIClientIntegrationTest and confirm a successful ChatGPT round trip through the proxy
  • Verify default behavior (no proxy-preferred-auth-schemes) still works with HttpClient defaults
  • When set (e.g. Basic,Digest), confirm preferred schemes are applied on the request config and CONNECT succeeds against a Digest-advertising proxy that only works with Basic
  • Confirm AI translate / AI review services still construct clients with the updated proxy config

Made with Cursor

@wadimw wadimw changed the title LXP-2163: Fix OpenAI webproxy auth with Apache HttpClient 5 Fix OpenAI webproxy auth with Apache HttpClient 5 Jul 30, 2026
@wadimw wadimw added the upstream-patched Experimental features ported from legacy branch label Jul 30, 2026

@wadimw wadimw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Conditionally approving for now - as discussed, we need to clean up the redundant test scaffolding and overall condense the proxy-related changes into a more focused diff. (My draft: #1071)

ehoogerbeets and others added 7 commits July 30, 2026 09:57
- We were attempting to use the Basic tunneling scheme to talk to
  webproxy, but the JDK turns it off by default, so queries
  through our webproxy server were silently hanging
Introduce l10n.webproxy settings with per-service overrides for backward
compatibility, an opt-in for Basic auth on HTTPS CONNECT, and a default
connect timeout so unreachable proxies fail quickly instead of hanging.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- This is an existing library that is already used in other parts of mojito
- It has no problems with authentication negotiation and a Authentication Bearer header
- Added OpenAIClientIntegrationTest which only runs when your
  company's OpenAI is configured in the properties files
    - Full, complete round trip simplistic query to ChatGPT as a smoke
      test to verify that everything connects properly before you go
      and test with a real server
    - Can test the webproxy support too
- if your proxy server says it supports "Digest" but in reality,
  it doesn't, or if you have some sort of other auth scheme that
  is not already in the default list, you can now change the schemes
  list with a new setting in the application.properties
@ehoogerbeets
ehoogerbeets force-pushed the fixProxyBearerToken2 branch from cb289ce to 3a2804a Compare July 30, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream-patched Experimental features ported from legacy branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants