Skip to content

Conversation

@ptarjan
Copy link
Contributor

@ptarjan ptarjan commented Dec 22, 2025

This change enables Bazel to work with authenticated HTTP proxies by:

  1. Reading proxy credentials from http.proxyUser/http.proxyPassword and https.proxyUser/https.proxyPassword system properties

  2. Setting the Proxy-Authorization header directly on HTTP connections to ensure proper authentication with the proxy server

  3. Automatically enabling Basic auth for HTTPS tunneling by clearing jdk.http.auth.tunneling.disabledSchemes (which defaults to "Basic")

  4. Using Java's Authenticator mechanism for HTTPS CONNECT tunneling, with RequestorType.PROXY check to prevent credential leakage

The ProxyHelper now returns a ProxyInfo object that contains both the Proxy and optional authentication credentials, allowing HttpConnector to set appropriate headers.

Fixes #14675
Fixes #7487
Fixes #6196
Fixes #26674
Related to #601
Related to #587
Related to #11374
Related to #15740
Related to #3993

@google-cla
Copy link

google-cla bot commented Dec 22, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Dec 22, 2025
@ptarjan ptarjan force-pushed the claude/fix-bazel-proxy-auth-HOYrA branch from f2ca315 to eddc40c Compare December 22, 2025 21:17
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for authenticated HTTP proxies in Bazel, a significant feature enhancement. The changes involve introducing a ProxyInfo class to handle proxy configurations and credentials, reading credentials from system properties, and using Java's Authenticator for HTTPS tunneling. While the implementation is thorough and includes extensive tests, I've identified a critical race condition concerning the use of the global Authenticator.setDefault. This could lead to authentication failures during parallel downloads. The rest of the implementation appears solid.

@ptarjan ptarjan force-pushed the claude/fix-bazel-proxy-auth-HOYrA branch from eddc40c to 7c4b023 Compare December 22, 2025 21:29
@ptarjan ptarjan force-pushed the claude/fix-bazel-proxy-auth-HOYrA branch 2 times, most recently from 24bd974 to 1f3857a Compare December 23, 2025 07:29
@ptarjan ptarjan force-pushed the claude/fix-bazel-proxy-auth-HOYrA branch from 1f3857a to 0573e72 Compare December 23, 2025 07:53
This change enables Bazel to work with authenticated HTTP proxies by:

1. Reading proxy credentials from http.proxyUser/http.proxyPassword and
   https.proxyUser/https.proxyPassword system properties

2. Setting the Proxy-Authorization header directly on HTTP connections
   to ensure proper authentication with the proxy server

3. Automatically enabling Basic auth for HTTPS tunneling by clearing
   jdk.http.auth.tunneling.disabledSchemes (which defaults to "Basic")

4. Using Java's Authenticator mechanism for HTTPS CONNECT tunneling,
   with RequestorType.PROXY check to prevent credential leakage

The ProxyHelper now returns a ProxyInfo object that contains both the
Proxy and optional authentication credentials, allowing HttpConnector
to set appropriate headers.

Fixes bazelbuild#14675
Fixes bazelbuild#7487
Fixes bazelbuild#6196
Fixes bazelbuild#26674
Related to bazelbuild#601
Related to bazelbuild#587
Related to bazelbuild#11374
Related to bazelbuild#15740
Related to bazelbuild#3993
@ptarjan ptarjan force-pushed the claude/fix-bazel-proxy-auth-HOYrA branch from 0573e72 to c4f0e10 Compare December 23, 2025 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

2 participants