mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Fix retrieval of credentials for URLs from cache (#6452)
While working on https://github.com/astral-sh/uv/pull/6389 I discovered we never checked `cache.get_url` here, which is wrong — though I don't think it had much effect in practice since the realm would typically match first. The main problem is that when we call `get_url` later we hard-code the username to `None` because we assume we checked up here with the username if present.
This commit is contained in:
parent
a535d3b131
commit
34dd8401ed
2 changed files with 8 additions and 1 deletions
|
@ -17,7 +17,7 @@ pub struct Credentials {
|
|||
password: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash, Default)]
|
||||
pub(crate) struct Username(Option<String>);
|
||||
|
||||
impl Username {
|
||||
|
|
|
@ -160,6 +160,13 @@ impl Middleware for AuthMiddleware {
|
|||
request = credentials.authenticate(request);
|
||||
// Do not insert already-cached credentials
|
||||
None
|
||||
} else if let Some(credentials) = self
|
||||
.cache()
|
||||
.get_url(request.url(), &credentials.to_username())
|
||||
{
|
||||
request = credentials.authenticate(request);
|
||||
// Do not insert already-cached credentials
|
||||
None
|
||||
} else if let Some(credentials) = self
|
||||
.fetch_credentials(Some(&credentials), request.url())
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue