Skip to content

Commit

Permalink
Fix retrieval of credentials for URLs from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Aug 22, 2024
1 parent fa34466 commit 7e652c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/uv-auth/src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions crates/uv-auth/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7e652c8

Please sign in to comment.