Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support basic auth in package-indices #5509

Closed
brandon-leapyear opened this issue Mar 25, 2021 · 4 comments · Fixed by commercialhaskell/pantry#32
Closed

Support basic auth in package-indices #5509

brandon-leapyear opened this issue Mar 25, 2021 · 4 comments · Fixed by commercialhaskell/pantry#32

Comments

@brandon-leapyear
Copy link
Contributor

Please follow the steps below for reporting a bug:

Make sure that you are using the latest release (currently stack-2.5.1).
See the upgrade instructions to upgrade.

Please use the following schema for your bug report:

General summary/comments (optional)

We're trying to set up a company internal proxy for Hackage, so we're trying to set download-prefix in package-indices to https://username:[email protected].

TL;DR pantry's get function in Hackage.Security.Client.Repository.HttpLib.HttpClient

Steps to reproduce

Specify a URL in download-prefix with username/password. rm -rf stack.yaml.lock. When running stack build, check network traces and notice that username/password isn't being propagated.

Expected

It should download files from our proxy with user credentials

Actual

First problem: we get an error about root.json:

Could not deserialize <repo>/root.json: Schema error: Expected field "signed"

which is weird because if we curl the URL, we load root.json fine. With some debug statements, we found out that our proxy is actually returning a JSON object saying Authentication is required. This ticket is filed here: haskell/hackage-security#251

So after debugging the first issue, we find out that stack is somehow not propagating the basic auth credentials. Then I printed out uri in Hackage.Security.Client.Repository.Remote.getFile.download and it shows the URI with the basic auth credentials, so up to that point it keeps the basic auth around. But then it calls httpGet which pantry implements in its own implementation of Hackage.Security.Client.Repository.HttpLib.HttpClient, and there it calls setRequestHeaders, which seems to override the Authorization header set in setUri.

Stack version

Built from master

Method of installation

  • Official binary, downloaded from stackage.org or fpcomplete's package repository
  • Via cabal-install
  • An unofficial package repository (please specify which)
  • Other (please specify)
@brandon-leapyear
Copy link
Contributor Author

brandon-leapyear commented Mar 25, 2021

This is an old work account. Please reference @brandonchinn178 for all future communication


Technically, the bug is in hackage-security/pantry, so I could cross post the issue, if you'd like. Regardless, I'll put up a PR

@brandon-leapyear
Copy link
Contributor Author

brandon-leapyear commented Mar 26, 2021 via email

snoyberg added a commit that referenced this issue Mar 26, 2021
@snoyberg
Copy link
Contributor

I just opened a PR #5510. Note that I didn't intentionally close this issue, looks like it was triggered by merging that PR.

snoyberg added a commit that referenced this issue Mar 26, 2021
@brandon-leapyear
Copy link
Contributor Author

brandon-leapyear commented Mar 26, 2021

This is an old work account. Please reference @brandonchinn178 for all future communication


Yeah, I figured. No worries!

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 a pull request may close this issue.

2 participants