Skip to content

Send proxy credentials from HTTP(S)_PROXY - #100

Open
fastjames wants to merge 2 commits into
elixir-lang:masterfrom
fastjames:proxy-auth
Open

fastjames wants to merge 2 commits into
elixir-lang:masterfrom
fastjames:proxy-auth

Conversation

@fastjames

Copy link
Copy Markdown

Closes #99.

ElixirMake.Downloader.Httpc dropped the credentials in the proxy URL, so a proxy that requires authentication answered the CONNECT with 407 and the precompiled download fell back to a source build. This passes them as httpc's proxy_auth, taken from the proxy for the URL's scheme, following Mix.Utils.proxy_config/1. As in Mix, a missing password becomes "" and the credentials aren't percent-decoded.

The second commit stops the Using HTTP(S)_PROXY messages from printing the password. It's separate in case you'd rather leave it out.

How I validated it:

  • Against a local proxy that records requests: with credentials in HTTPS_PROXY, the CONNECT now sends Proxy-Authorization: Basic …, where before it sent none. Without credentials there's no header, a username without a password sends user:, and an http:// URL uses HTTP_PROXY's credentials rather than HTTPS_PROXY's.
  • Through a real authenticating proxy: lazy_html 0.1.13's precompiled NIF now downloads (it got a 407 before), and its sha256 matches the package's checksum.exs.
  • mix format --check-formatted, mix compile --warnings-as-errors and mix test pass on Elixir 1.19.1 / OTP 28.

I didn't add a test, since the last downloader test was removed in 1b1a9a9. Happy to add one if you'd like.

httpc ignores the userinfo in a proxy URL, so a proxy that requires
authentication rejected the CONNECT with 407 and the precompiled
download fell back to a source build. Pass the credentials as
proxy_auth, taken from the proxy for the URL's scheme, as
Mix.Utils.proxy_config/1 does.

Closes elixir-lang#99
The "Using HTTP(S)_PROXY" messages printed the proxy URL as given,
password included, into build logs.

@josevalim josevalim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Precompiled download drops credentials in HTTP(S)_PROXY and fails with 407

2 participants