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

Upgrades #532

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
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
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,37 @@ missing_docs = "deny"
all = "deny"

[dependencies]
async-trait = "0.1.83"
bitflags = "2.6.0"
async-trait = "0.1.85"
bitflags = "2.8.0"
bytes = "1.9.0"
chrono = { version = "0.4.39", default-features = false, features = ["clock", "std"] }
derive_more = { version = "0.99.18", features = ["display"] }
derive_more = { version = "1.0.0", features = ["display"] }
futures-util = { version = "0.3.31", default-features = false, features = ["alloc", "sink"] }
getrandom = "0.2.15"
lazy_static = "1.5.0"
md-5 = "0.10.6"
moka = { version = "0.12.8", default-features = false, features = ["sync"] }
moka = { version = "0.12.10", default-features = false, features = ["sync"] }
nix = { version = "0.29.0", default-features = false, features = ["fs"] }
prometheus = { version = "0.13.4", default-features = false }
proxy-protocol = "0.5.0"
rustls = "0.23.20"
rustls = "0.23.21"
rustls-pemfile = "2.2.0"
slog = { version = "2.7.0", features = ["max_level_trace", "release_max_level_info"] }
slog-stdlog = "4.1.1"
thiserror = "1.0.69"
tokio = { version = "1.42.0", features = ["macros", "rt", "net", "process", "sync", "io-util", "time"] }
thiserror = "2.0.11"
tokio = { version = "1.43.0", features = ["macros", "rt", "net", "process", "sync", "io-util", "time"] }
tokio-rustls = "0.26.1"
tokio-util = { version = "0.7.13", features = ["codec"] }
tracing = { version = "0.1.41", default-features = false }
tracing-attributes = "0.1.28"
uuid = { version = "1.11.0", features = ["v4"] }
uuid = { version = "1.12.0", features = ["v4"] }
x509-parser = "0.16.0"
dashmap = "5.5.3"
dashmap = "6.1.0"
libc = "0.2"

[dev-dependencies]
pretty_assertions = "1.4.1"
tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
unftp-sbe-fs = { path = "../libunftp/crates/unftp-sbe-fs" }

[lints]
Expand Down
14 changes: 7 additions & 7 deletions crates/unftp-auth-jsonfile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ repository = "https://github.com/bolcom/libunftp/tree/master/crates/unftp-auth-j
readme = "README.md"

[dependencies]
async-trait = "0.1.83"
base64 = "0.21.7"
async-trait = "0.1.85"
base64 = "0.22.1"
bytes = "1.9.0"
ipnet = "2.10.1"
iprange = "0.6.7"
libunftp = { version = "0.20.3", path = "../../" }
ring = "0.16.20"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.133"
tokio = { version = "1.42.0", features = ["rt", "time"] }
ring = "0.17.8"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.135"
tokio = { version = "1.43.0", features = ["rt", "time"] }
tracing = { version = "0.1.41", default-features = false }
tracing-attributes = "0.1.28"
valid = "0.3.1"
flate2 = "1.0.35"

[dev-dependencies]
pretty_env_logger = "0.5.0"
tokio = { version = "1.42.0", features = ["macros"] }
tokio = { version = "1.43.0", features = ["macros"] }
unftp-sbe-fs = { version = "0.2.2", path = "../unftp-sbe-fs" }

[lints]
Expand Down
4 changes: 2 additions & 2 deletions crates/unftp-auth-pam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repository = "https://github.com/bolcom/libunftp/tree/master/crates/unftp-auth-p
readme = "README.md"

[dependencies]
async-trait = "0.1.83"
async-trait = "0.1.85"
libunftp = { version = "0.20.3", path = "../../" }
tracing = { version = "0.1.41", default-features = false }
tracing-attributes = "0.1.28"
Expand All @@ -28,7 +28,7 @@ tracing-attributes = "0.1.28"
pam-auth = { package = "pam", version = "0.7.0" }

[dev-dependencies]
tokio = { version = "1.42.0", features = ["macros"] }
tokio = { version = "1.43.0", features = ["macros"] }

[lints]
workspace = true
16 changes: 9 additions & 7 deletions crates/unftp-auth-rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,24 @@ repository = "https://github.com/bolcom/libunftp/tree/hannes/crates/unftp-auth-r
readme = "README.md"

[dependencies]
async-trait = "0.1.83"
hyper = { version = "0.14.31", features = ["client", "runtime", "stream", "http1"] }
hyper-rustls = "0.24.2"
async-trait = "0.1.85"
http-body-util = "0.1.2"
hyper = { version = "1.5.2", features = ["client", "http1"] }
hyper-rustls = "0.27.5"
hyper-util = "0.1.10"
libunftp = { version = "0.20.3", path = "../../" }
percent-encoding = "2.3.1"
regex = "1.11.1"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.133"
tokio = { version = "1.42.0", features = ["rt", "net", "sync", "io-util", "time"] }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.135"
tokio = { version = "1.43.0", features = ["rt", "net", "sync", "io-util", "time"] }
tracing = { version = "0.1.41", default-features = false }
tracing-attributes = "0.1.28"


[dev-dependencies]
pretty_env_logger = "0.5.0"
tokio = { version = "1.42.0", features = ["macros"] }
tokio = { version = "1.43.0", features = ["macros"] }
unftp-sbe-fs = { version = "0.2.2", path = "../unftp-sbe-fs" }

[lints]
Expand Down
20 changes: 14 additions & 6 deletions crates/unftp-auth-rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
//!

use async_trait::async_trait;
use hyper::{http::uri::InvalidUri, Body, Client, Method, Request};
use http_body_util::BodyExt;
use hyper::{http::uri::InvalidUri, Method, Request};
use hyper_util::client::legacy::Client;
use hyper_util::rt::TokioExecutor;
use libunftp::auth::{AuthenticationError, Authenticator, Credentials, DefaultUser};
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use regex::Regex;
Expand Down Expand Up @@ -249,27 +252,32 @@ impl Authenticator<DefaultUser> for RestAuthenticator {
.method(&self.method)
.header("Content-type", "application/json")
.uri(url)
.body(Body::from(body))
.body(body)
.map_err(|e| AuthenticationError::with_source("rest authenticator http client error", e))?;

let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.expect("no native root CA certificates found")
.https_or_http()
.enable_http1()
.build();

let client = Client::builder().build(https);
let client = Client::builder(TokioExecutor::new()).build(https);

let resp = client
.request(req)
.await
.map_err(|e| AuthenticationError::with_source("rest authenticator http client error", e))?;

let body_bytes = hyper::body::to_bytes(resp.into_body())
let (parts, body) = resp.into_parts();
let status_context = format!("http status={}", parts.status.as_str());
let body = BodyExt::collect(body)
.await
.map_err(|e| AuthenticationError::with_source("rest authenticator http client error", e))?;
.map_err(|e| AuthenticationError::with_source(format!("error while receiving http response ({})", status_context), e))?
.to_bytes();
let body: Value = serde_json::from_slice(&body)
.map_err(|e| AuthenticationError::with_source(format!("rest authenticator unmarshalling error ({})", status_context), e))?;

let body: Value = serde_json::from_slice(&body_bytes).map_err(|e| AuthenticationError::with_source("rest authenticator unmarshalling error", e))?;
let parsed = match body.pointer(&self.selector) {
Some(parsed) => parsed.to_string(),
None => json!(null).to_string(),
Expand Down
16 changes: 8 additions & 8 deletions crates/unftp-sbe-fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ repository = "https://github.com/bolcom/libunftp/tree/master/crates/unftp-sbe-fs
readme = "README.md"

[dependencies]
async-trait = "0.1.83"
async-trait = "0.1.85"
cfg-if = "1.0"
cap-std = "3.4"
futures = { version = "0.3.31", default-features = false, features = ["std"] }
lazy_static = "1.5.0"
libunftp = { version = "0.20.3", path = "../../" }
path_abs = "0.5.1"
tokio = { version = "1.42.0", features = ["rt", "net", "sync", "io-util", "time", "fs"] }
tokio = { version = "1.43.0", features = ["rt", "net", "sync", "io-util", "time", "fs"] }
tokio-stream = "0.1.17"
tracing = { version = "0.1.41", default-features = false }
tracing-attributes = "0.1.28"

[dev-dependencies]
async_ftp = "6.0.0"
async-trait = "0.1.83"
async-trait = "0.1.85"
chrono = "0.4.39"
more-asserts = "0.3.1"
nix = { version = "0.29.0", default-features = false, features = ["user"] }
pretty_assertions = "1.4.1"
pretty_env_logger = "0.5.0"
regex = "1.11.1"
rstest = "0.18.2"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.133"
rstest = "0.24.0"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.135"
slog-async = "2.8.0"
slog-term = "2.9.1"
tempfile = "3.14.0"
tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread"] }
tempfile = "3.15.0"
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
tracing-subscriber = "0.3.19"
getrandom = "0.2.15"

Expand Down
24 changes: 13 additions & 11 deletions crates/unftp-sbe-gcs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,31 @@ repository = "https://github.com/bolcom/libunftp/tree/master/crates/unftp-sbe-gc
readme = "README.md"

[dependencies]
async-trait = "0.1.83"
base64 = "0.21.7"
async-trait = "0.1.85"
base64 = "0.22.1"
bytes = "1.9.0"
chrono = { version = "0.4.39", default-features = false, features = ["std", "serde"] }
futures = { version = "0.3.31", default-features = false, features = ["std"] }
hyper = { version = "0.14.31", features = ["client", "runtime", "stream", "http1"] }
hyper-rustls = "0.24.2"
http-body-util = "0.1.2"
hyper = { version = "1.5.2", features = ["client", "http1"] }
hyper-rustls = "0.27.5"
hyper-util = "0.1.10"
libunftp = { version = "0.20.3", path = "../../" }
mime = "0.3.17"
percent-encoding = "2.3.1"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.133"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.135"
time = "0.3.37"
tokio = { version = "1.42.0", features = ["rt", "net", "sync", "io-util", "time", "fs"] }
tokio = { version = "1.43.0", features = ["rt", "net", "sync", "io-util", "time", "fs"] }
tokio-stream = "0.1.17"
tokio-util = { version = "0.7.13", features = ["codec", "compat"] }
tracing = { version = "0.1.41", default-features = false }
tracing-attributes = "0.1.28"
yup-oauth2 = "8.3.2"
yup-oauth2 = { version = "11.0.0", default-features = false, features = ["hyper-rustls", "service-account", "aws-lc-rs"]}

[dev-dependencies]
async_ftp = "6.0.0"
clap = { version = "3.2.25", features = ["env"] }
clap = { version = "4.5.26", features = ["env"] }
lazy_static = "1.5.0"
more-asserts = "0.3.1"
path_abs = "0.5.1"
Expand All @@ -50,6 +52,6 @@ slog = { version = "2.7.0", features = ["max_level_trace", "release_max_level_in
slog-async = "2.8.0"
slog-stdlog = "4.1.1"
slog-term = "2.9.1"
tempfile = "3.14.0"
tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread"] }
tempfile = "3.15.0"
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
tracing-subscriber = "0.3.19"
53 changes: 23 additions & 30 deletions crates/unftp-sbe-gcs/examples/gcs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use clap::{Arg, Command};
use libunftp::ServerBuilder;
use std::{error::Error, path::PathBuf};
use tracing::Level;
use unftp_sbe_gcs::options::AuthMethod;

// To run this example with the local fake GCS (see tests/resources/gcs_test.sh) instead of Google GCS,
// after starting fake-gcs-server, run this example with
Expand Down Expand Up @@ -38,7 +40,7 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
.value_name("SERVICE_ACCOUNT_KEY")
.env("LIBUNFTP_SERVICE_ACCOUNT_KEY")
.help("The service account key JSON file of the Google Cloud Storage bucket to be used")
.required(true),
.required(false),
)
.arg(
Arg::new(FAKE_GCS_BASE_URL)
Expand Down Expand Up @@ -69,41 +71,32 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
)
.get_matches();

let service_account_key_path = matches
.value_of(SERVICE_ACCOUNT_KEY)
.ok_or("Internal error: use of an undefined command line parameter")?;
let bucket_name = matches
.value_of(BUCKET_NAME)
.ok_or("Internal error: use of an undefined command line parameter")?
.to_owned();
let gcs_base_url = if let Some(base_url) = matches.value_of(FAKE_GCS_BASE_URL) {
let service_account_key_path = matches.get_one::<String>(SERVICE_ACCOUNT_KEY);
let bucket_name = matches.get_one::<String>(BUCKET_NAME).unwrap().to_owned();
let gcs_base_url = if let Some(base_url) = matches.get_one::<String>(FAKE_GCS_BASE_URL) {
String::from(base_url)
} else {
String::from("https://www.googleapis.com")
};

let service_account_key: Vec<u8> = tokio::fs::read(service_account_key_path).await?;
if let Some(ftps_certs_file) = matches.value_of(FTPS_CERTS_FILE) {
let ftps_key_file = matches
.value_of(FTPS_KEY_FILE)
.ok_or("Internal error: use of an undefined command line parameter")?;
libunftp::ServerBuilder::new(Box::new(move || {
unftp_sbe_gcs::CloudStorage::with_api_base(&gcs_base_url, &bucket_name, PathBuf::new(), service_account_key.clone())
}))
.ftps(ftps_certs_file, ftps_key_file)
.build()
.unwrap()
.listen(BIND_ADDRESS)
.await?;
let service_account_key: Option<Vec<u8>> = match service_account_key_path {
Some(key_path) => Some(tokio::fs::read(key_path).await?),
None => None,
};

let mut builder = ServerBuilder::new(Box::new(move || match &service_account_key {
Some(key) => unftp_sbe_gcs::CloudStorage::with_api_base(&gcs_base_url, &bucket_name, PathBuf::new(), key.clone()),
None => unftp_sbe_gcs::CloudStorage::with_api_base(&gcs_base_url, &bucket_name, PathBuf::new(), AuthMethod::None),
}));

builder = if let Some(ftps_certs_file) = matches.get_one::<String>(FTPS_CERTS_FILE) {
let ftps_key_file = matches.get_one::<String>(FTPS_KEY_FILE).unwrap();
builder.ftps(ftps_certs_file, ftps_key_file)
} else {
libunftp::ServerBuilder::new(Box::new(move || {
unftp_sbe_gcs::CloudStorage::with_api_base(&gcs_base_url, &bucket_name, PathBuf::new(), service_account_key.clone())
}))
.build()
.unwrap()
.listen(BIND_ADDRESS)
.await?;
}
builder
};

builder.build().unwrap().listen(BIND_ADDRESS).await?;

Ok(())
}
Loading
Loading