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

Add support for retrieving credentials from keyring #2254

Merged
merged 33 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7193418
Basic implementation of keyring support
BakerNet Mar 6, 2024
f42ed8f
Better argument description
BakerNet Mar 6, 2024
82dd007
move keyring auth to middleware
BakerNet Mar 7, 2024
c7ee0b0
clippy
BakerNet Mar 7, 2024
0294317
Use lazy_static for memoization
BakerNet Mar 7, 2024
d785d55
more unit tests
BakerNet Mar 7, 2024
f791d71
typo
BakerNet Mar 7, 2024
62393d5
clippy
BakerNet Mar 7, 2024
efd0a18
Review changs Round 1
BakerNet Mar 8, 2024
d9be41d
Review changes Round 1.1
BakerNet Mar 8, 2024
bac29c1
clippy
BakerNet Mar 8, 2024
54f8c8a
AuthenticationStore progress
BakerNet Mar 8, 2024
32b2e35
AuthenticationStore completed
BakerNet Mar 9, 2024
5b1dd56
Merge with master
BakerNet Mar 9, 2024
cea115e
Clippy
BakerNet Mar 9, 2024
39bcb7a
Merge remote-tracking branch 'upstream/main' into feature/basic-use-k…
BakerNet Mar 10, 2024
cdbea4e
Update to use Middleware instead of RequestInitializer
BakerNet Mar 10, 2024
ea63122
Use keyring-provider to match pip interface
BakerNet Mar 10, 2024
803ad1a
fmt
BakerNet Mar 10, 2024
6123dfd
Change set_from_url
BakerNet Mar 11, 2024
177bdee
Merge remote-tracking branch 'upstream/main' into feature/basic-use-k…
BakerNet Mar 11, 2024
ba488bc
support UV_KEYRING_SUBPROCESS env var
Mar 12, 2024
75dc306
Merge remote-tracking branch 'upstream/main' into feature/basic-use-k…
BakerNet Mar 12, 2024
1594462
Merge pull request #1 from thomasgilgenast/keyring
BakerNet Mar 12, 2024
36d43f0
Update crates/uv-auth/src/store.rs
BakerNet Mar 12, 2024
5fff276
Review Round 2
BakerNet Mar 12, 2024
fd05e73
Docstring
BakerNet Mar 12, 2024
2cf1094
Warn on keyring error
BakerNet Mar 12, 2024
984fd59
Merge branch 'main' into feature/basic-use-keyring
BakerNet Mar 13, 2024
322b09e
Review Round 3
BakerNet Mar 13, 2024
b281499
Merge remote-tracking branch 'upstream/main' into feature/basic-use-k…
BakerNet Mar 13, 2024
93d8b30
wiremock bump to avoid dependancy mismatch
BakerNet Mar 13, 2024
31cd4e4
Merge remote-tracking branch 'upstream/main' into feature/basic-use-k…
BakerNet Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 171 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ indicatif = { version = "0.17.7" }
indoc = { version = "2.0.4" }
itertools = { version = "0.12.1" }
junction = { version = "1.0.0" }
lazy_static = { version = "1.4.0" }
mailparse = { version = "0.14.0" }
miette = { version = "6.0.0" }
nanoid = { version = "0.4.0" }
Expand Down Expand Up @@ -94,7 +95,7 @@ tempfile = { version = "3.9.0" }
textwrap = { version = "0.16.1" }
thiserror = { version = "1.0.56" }
tl = { version = "0.7.7" }
tokio = { version = "1.35.1", features = ["rt-multi-thread"] }
tokio = { version = "1.35.1", features = ["rt-multi-thread", "macros"] }
tokio-stream = { version = "0.1.14" }
tokio-tar = { version = "0.3.1" }
tokio-util = { version = "0.7.10", features = ["compat"] }
Expand All @@ -108,6 +109,7 @@ unicode-width = { version = "0.1.11" }
unscanny = { version = "0.1.0" }
url = { version = "2.5.0" }
urlencoding = { version = "2.1.3" }
wiremock = { version = "0.6.0" }
walkdir = { version = "2.5.0" }
which = { version = "6.0.0" }
winapi = { version = "0.3.9" }
Expand Down
12 changes: 5 additions & 7 deletions crates/distribution-types/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use thiserror::Error;
use pep440_rs::{VersionSpecifiers, VersionSpecifiersParseError};
use pypi_types::{DistInfoMetadata, Hashes, Yanked};
use url::Url;
use uv_auth::safe_copy_url_auth_to_str;
use uv_auth::AuthenticationStore;

/// Error converting [`pypi_types::File`] to [`distribution_type::File`].
#[derive(Debug, Error)]
Expand Down Expand Up @@ -53,12 +53,10 @@ impl File {
size: file.size,
upload_time_utc_ms: file.upload_time.map(|dt| dt.timestamp_millis()),
url: if file.url.contains("://") {
let url = safe_copy_url_auth_to_str(base, &file.url)
.map_err(|err| FileConversionError::Url(file.url.clone(), err))?
.map(|url| url.to_string())
.unwrap_or(file.url);

FileLocation::AbsoluteUrl(url)
let url = Url::parse(&file.url)
.map_err(|err| FileConversionError::Url(file.url.clone(), err))?;
let url = AuthenticationStore::with_url_encoded_auth(url);
Copy link
Member

Choose a reason for hiding this comment

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

So the assumption here is that we've already hit the base URL on a previous invocation of the middleware, and so its credentials are already stored in the AuthenticationStore, and will be propagated here if needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was my assumption. That if base has auth, it received it from a copy from a previous request (in FlatIndexClient.read_from_url or RegistryClient.simple_single_index).

FileLocation::AbsoluteUrl(url.to_string())
} else {
FileLocation::RelativeUrl(base.to_string(), file.url)
},
Expand Down
16 changes: 15 additions & 1 deletion crates/uv-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,19 @@ version = "0.0.1"
edition = "2021"

[dependencies]
url = { workspace = true }
async-trait = { workspace = true }
base64 = { workspace = true }
clap = { workspace = true, features = ["derive", "env"], optional = true }
lazy_static = { workspace = true }
reqwest = { workspace = true }
reqwest-middleware = { workspace = true }
rust-netrc = { workspace = true }
task-local-extensions = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }

[dev-dependencies]
tempfile = { workspace = true }
tokio = { workspace = true }
wiremock = { workspace = true }
Loading
Loading