Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ log = { version = "0.4.29", default-features = false }
pubgrub = { version = "0.3.0", default-features = false }
# partialzip = { version = "5.0.0", default-features = false, optional = true }
pyo3 = { version = "0.28.2", default-features = false, features = ["macros", "chrono", "indexmap"], optional = true }
reqwest-middleware = { version = "0.5.1" }
reqwest-middleware = { version = "0.5.1", features = ["multipart"] }
semver = { version = "1.0.27", features = ["serde"] }
serde = { version = "1.0.228", features = ["derive"] }
serde_json = { version = "1.0.149", default-features = false, features = ["preserve_order"] }
Expand All @@ -67,7 +67,7 @@ tokio = { version = "1.50.0", default-features = false, features = ["rt", "io-ut
bytes = { version = "1.11.1", default-features = false }
toml_edit = { version = "0.25.4", features = ["serde"] }
globset = { version = "0.4.18", default-features = false }
reqwest = { version = "0.13.2", optional = true, features = ["rustls", "stream"] }
reqwest = { version = "0.13.2", optional = true, features = ["rustls", "stream", "multipart"] }
dunce = "1.0.5"

[dev-dependencies]
Expand Down
25 changes: 25 additions & 0 deletions core/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,31 @@ pub type StandardHTTPAuthentication = RestrictAuthentication<
Unauthenticated,
>;

/// Publish-specific HTTP authentication policy where matching URL globs always use bearer auth.
pub type PublishHTTPAuthentication = RestrictAuthentication<ForceBearerAuth, Unauthenticated>;

impl StandardHTTPAuthentication {
pub fn into_publish_authentication(self) -> Result<PublishHTTPAuthentication, globset::Error> {
let mut partial = GlobMapBuilder::new();

for (key, sequence_auth) in self
.restricted
.keys
.into_iter()
.zip(self.restricted.values.into_iter())
{
if let StandardInnerAuthentication::BearerAuth(inner) = sequence_auth.lower {
partial.add(key, inner);
}
}

Ok(PublishHTTPAuthentication {
restricted: partial.build()?,
unrestricted: Unauthenticated {},
})
}
}

/// Utility to simplify construction of `StandardHTTPAuthentication`
#[derive(Debug, Default, Clone)]
pub struct StandardHTTPAuthenticationBuilder {
Expand Down
2 changes: 2 additions & 0 deletions core/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub mod include;
pub mod info;
pub mod init;
pub mod lock;
#[cfg(all(feature = "filesystem", feature = "networking"))]
pub mod publish;
pub mod remove;
#[cfg(feature = "filesystem")]
pub mod root;
Expand Down
Loading
Loading