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

feat: Add netrc authentication to uv-client #2241

Merged
merged 3 commits into from
Mar 6, 2024

Conversation

bschoenmaeckers
Copy link
Contributor

Summary

Add netrc support to the uv-client.

closes #1405

Test Plan

I've added a corresponding test case to validate the correct header. Furthermore a tested it against a real world private repository.

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

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

Thanks for the thorough test!

@zanieb zanieb added the enhancement New feature or request label Mar 6, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) March 6, 2024 20:40
@charliermarsh charliermarsh merged commit e774207 into astral-sh:main Mar 6, 2024
7 checks passed
charliermarsh added a commit that referenced this pull request Mar 10, 2024
## Summary

The netrc middleware we added in
#2241 has a slight problem. If you
include credentials in your index URL, _and_ in the netrc file, the
crate blindly adds the netrc credentials as a header. And given the
`ReqwestBuilder` API, this means you end up with _two_ `Authorization`
headers, which always leads to an invalid request, though the exact
failure can take different forms.

This PR removes the middleware crate in favor of our own middleware.
Instead of using the `RequestInitialiser` API, we have to use the
`Middleware` API, so that we can remove the header on the request
itself.

Closes #2323.

## Test Plan

- Verified that running against a private index with credentials in the
URL (but no netrc file) worked without error.
- Verified that running against a private index with credentials in the
netrc file (but not the URL) worked without error.
- Verified that running against a private index with a mix of
credentials in both _also_ worked without error.
@bschoenmaeckers bschoenmaeckers deleted the netrc branch March 26, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support .netrc files
3 participants