Add in-URL credentials to store prior to creating requests (#2446)

## Summary

The authentication middleware extracts in-URL credentials from URLs that
pass through it; however, by the time a request reaches the store, the
credentials will have already been removed, and relocated to the header.
So we were never propagating in-URL credentials.

This PR adds an explicit pass wherein we pass in-URL credentials to the
store prior to doing any work.

Closes https://github.com/astral-sh/uv/issues/2444.

## Test Plan

`cargo run pip install` against an authenticated AWS registry.
This commit is contained in:
Charlie Marsh 2024-03-13 20:46:33 -07:00 committed by GitHub
parent d29645ce75
commit f1aec3e779
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 53 additions and 22 deletions

View file

@ -57,21 +57,6 @@ pub struct BaseUrl(
);
impl BaseUrl {
/// Parse the given URL. If it's relative, join it to the current [`BaseUrl`]. Allows for
/// parsing URLs that may be absolute or relative, with a known base URL.
pub fn join_relative(&self, url: &str) -> Result<Url, url::ParseError> {
match Url::parse(url) {
Ok(url) => Ok(url),
Err(err) => {
if err == url::ParseError::RelativeUrlWithoutBase {
self.0.join(url)
} else {
Err(err)
}
}
}
}
/// Return the underlying [`Url`].
pub fn as_url(&self) -> &Url {
&self.0