diff options
-rw-r--r-- | Cargo.lock | 227 | ||||
-rw-r--r-- | Cargo.toml | 6 | ||||
-rw-r--r-- | src/login/ldap_provider.rs | 2 | ||||
-rw-r--r-- | src/login/static_provider.rs | 2 | ||||
-rw-r--r-- | src/storage/garage.rs | 38 |
5 files changed, 164 insertions, 111 deletions
@@ -46,7 +46,7 @@ dependencies = [ "eml-codec", "futures", "hex", - "hyper-rustls", + "hyper-rustls 0.26.0", "hyper-util", "im", "imap-codec", @@ -468,11 +468,11 @@ dependencies = [ "aws-sdk-ssooidc", "aws-sdk-sts", "aws-smithy-async", - "aws-smithy-http 0.60.6", + "aws-smithy-http", "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "aws-types", "bytes", "fastrand 2.0.1", @@ -494,7 +494,7 @@ checksum = "e5635d8707f265c773282a22abe1ecd4fbe96a8eb2f0f14c0796f8016f11a41a" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "zeroize", ] @@ -505,12 +505,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f82b9ae2adfd9d6582440d0eeb394c07f74d21b4c0cc72bdb73735c9e1a9c0e" dependencies = [ "aws-credential-types", - "aws-sigv4 1.1.6", + "aws-sigv4", "aws-smithy-async", "aws-smithy-eventstream", - "aws-smithy-http 0.60.6", + "aws-smithy-http", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "aws-types", "bytes", "fastrand 2.0.1", @@ -523,6 +523,28 @@ dependencies = [ ] [[package]] +name = "aws-sdk-config" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cb71960e3e197c3f512f3bf0f47f444acd708db59733416107ec2ff161ff5c4" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.11", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] name = "aws-sdk-s3" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -530,15 +552,15 @@ checksum = "5076637347e7d0218e61facae853110682ae58efabd2f4e2a9e530c203d5fa7b" dependencies = [ "aws-credential-types", "aws-runtime", - "aws-sigv4 1.1.6", + "aws-sigv4", "aws-smithy-async", "aws-smithy-checksums", "aws-smithy-eventstream", - "aws-smithy-http 0.60.6", + "aws-smithy-http", "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "aws-smithy-xml", "aws-types", "bytes", @@ -560,11 +582,11 @@ dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", - "aws-smithy-http 0.60.6", + "aws-smithy-http", "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "aws-types", "bytes", "http 0.2.11", @@ -582,11 +604,11 @@ dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", - "aws-smithy-http 0.60.6", + "aws-smithy-http", "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "aws-types", "bytes", "http 0.2.11", @@ -604,12 +626,12 @@ dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", - "aws-smithy-http 0.60.6", + "aws-smithy-http", "aws-smithy-json", "aws-smithy-query", "aws-smithy-runtime", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "aws-smithy-xml", "aws-types", "http 0.2.11", @@ -620,34 +642,15 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "0.55.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d2ce6f507be68e968a33485ced670111d1cbad161ddbbab1e313c03d37d8f4c" -dependencies = [ - "aws-smithy-http 0.55.3", - "form_urlencoded", - "hex", - "hmac", - "http 0.2.11", - "once_cell", - "percent-encoding", - "regex", - "sha2", - "time", - "tracing", -] - -[[package]] -name = "aws-sigv4" version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "404c64a104188ac70dd1684718765cb5559795458e446480e41984e68e57d888" dependencies = [ "aws-credential-types", "aws-smithy-eventstream", - "aws-smithy-http 0.60.6", + "aws-smithy-http", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "bytes", "crypto-bigint 0.5.5", "form_urlencoded", @@ -683,8 +686,8 @@ version = "0.60.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fd4b66f2a8e7c84d7e97bda2666273d41d2a2e25302605bcf906b7b2661ae5e" dependencies = [ - "aws-smithy-http 0.60.6", - "aws-smithy-types 1.1.7", + "aws-smithy-http", + "aws-smithy-types", "bytes", "crc32c", "crc32fast", @@ -704,40 +707,20 @@ version = "0.60.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6363078f927f612b970edf9d1903ef5cef9a64d1e8423525ebb1f0a1633c858" dependencies = [ - "aws-smithy-types 1.1.7", + "aws-smithy-types", "bytes", "crc32fast", ] [[package]] name = "aws-smithy-http" -version = "0.55.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b3b693869133551f135e1f2c77cb0b8277d9e3e17feaf2213f735857c4f0d28" -dependencies = [ - "aws-smithy-types 0.55.3", - "bytes", - "bytes-utils", - "futures-core", - "http 0.2.11", - "http-body 0.4.6", - "hyper 0.14.28", - "once_cell", - "percent-encoding", - "pin-project-lite 0.2.13", - "pin-utils", - "tracing", -] - -[[package]] -name = "aws-smithy-http" version = "0.60.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6ca214a6a26f1b7ebd63aa8d4f5e2194095643023f9608edf99a58247b9d80d" dependencies = [ "aws-smithy-eventstream", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "bytes", "bytes-utils", "futures-core", @@ -756,7 +739,7 @@ version = "0.60.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1af80ecf3057fb25fe38d1687e94c4601a7817c6a1e87c1b0635f7ecb644ace5" dependencies = [ - "aws-smithy-types 1.1.7", + "aws-smithy-types", ] [[package]] @@ -765,7 +748,7 @@ version = "0.60.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb27084f72ea5fc20033efe180618677ff4a2f474b53d84695cfe310a6526cbc" dependencies = [ - "aws-smithy-types 1.1.7", + "aws-smithy-types", "urlencoding", ] @@ -776,16 +759,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbb5fca54a532a36ff927fbd7407a7c8eb9c3b4faf72792ba2965ea2cad8ed55" dependencies = [ "aws-smithy-async", - "aws-smithy-http 0.60.6", + "aws-smithy-http", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "bytes", "fastrand 2.0.1", - "h2", + "h2 0.3.24", "http 0.2.11", "http-body 0.4.6", "hyper 0.14.28", - "hyper-rustls", + "hyper-rustls 0.24.2", "once_cell", "pin-project-lite 0.2.13", "pin-utils", @@ -801,7 +784,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22389cb6f7cac64f266fb9f137745a9349ced7b47e0d2ba503e9e40ede4f7060" dependencies = [ "aws-smithy-async", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "bytes", "http 0.2.11", "http 1.0.0", @@ -813,19 +796,6 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "0.55.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a3d0bf4f324f4ef9793b86a1701d9700fbcdbd12a846da45eed104c634c6e8" -dependencies = [ - "base64-simd", - "itoa", - "num-integer", - "ryu", - "time", -] - -[[package]] -name = "aws-smithy-types" version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f081da5481210523d44ffd83d9f0740320050054006c719eae0232d411f024d3" @@ -865,7 +835,7 @@ dependencies = [ "aws-credential-types", "aws-smithy-async", "aws-smithy-runtime-api", - "aws-smithy-types 1.1.7", + "aws-smithy-types", "http 0.2.11", "rustc_version", "tracing", @@ -1738,6 +1708,25 @@ dependencies = [ ] [[package]] +name = "h2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap 2.1.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1842,6 +1831,19 @@ dependencies = [ ] [[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "pin-project-lite 0.2.13", +] + +[[package]] name = "httparse" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1869,7 +1871,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.24", "http 0.2.11", "http-body 0.4.6", "httparse", @@ -1890,8 +1892,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" dependencies = [ "bytes", + "futures-channel", + "futures-util", + "h2 0.4.2", "http 1.0.0", "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", "pin-project-lite 0.2.13", "smallvec", "tokio", @@ -1909,12 +1917,31 @@ dependencies = [ "hyper 0.14.28", "log", "rustls 0.21.10", - "rustls-native-certs", + "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", ] [[package]] +name = "hyper-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +dependencies = [ + "futures-util", + "http 1.0.0", + "hyper 1.2.0", + "hyper-util", + "log", + "rustls 0.22.2", + "rustls-native-certs 0.7.0", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.25.0", + "tower-service", +] + +[[package]] name = "hyper-timeout" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1939,6 +1966,8 @@ dependencies = [ "http-body 1.0.0", "hyper 1.2.0", "pin-project-lite 0.2.13", + "socket2 0.5.5", + "tokio", "tower", "tower-service", "tracing", @@ -2118,14 +2147,17 @@ dependencies = [ [[package]] name = "k2v-client" version = "0.0.4" -source = "git+https://git.deuxfleurs.fr/Deuxfleurs/garage.git?tag=v0.9.1#ee57dd922b9c396298473b41e4046c8d00ee77d5" +source = "git+https://git.deuxfleurs.fr/Deuxfleurs/garage.git?branch=k2v/shared_http_client#8b35a946d9f6b31b26b9783acbfab984316051f4" dependencies = [ - "aws-sigv4 0.55.3", + "aws-sdk-config", + "aws-sigv4", "base64 0.21.7", "hex", - "http 0.2.11", - "hyper 0.14.28", - "hyper-rustls", + "http 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-rustls 0.26.0", + "hyper-util", "log", "percent-encoding", "serde", @@ -2178,7 +2210,7 @@ dependencies = [ "percent-encoding", "ring 0.16.20", "rustls 0.20.9", - "rustls-native-certs", + "rustls-native-certs 0.6.3", "thiserror", "tokio", "tokio-rustls 0.23.4", @@ -2948,6 +2980,19 @@ dependencies = [ ] [[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.0.0", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] name = "rustls-pemfile" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3562,7 +3607,7 @@ dependencies = [ "axum", "base64 0.21.7", "bytes", - "h2", + "h2 0.3.24", "http 0.2.11", "http-body 0.4.6", "hyper 0.14.28", @@ -48,15 +48,15 @@ rand = "0.8.5" rustls = "0.22" rustls-pemfile = "2.0" tokio-rustls = "0.25" -hyper-rustls = { version = "0.24", features = ["http2"] } -hyper-util = { version = "0.1", features = ["client"] } +hyper-rustls = { version = "0.26", features = ["http2"] } +hyper-util = { version = "0.1", features = ["full"] } rpassword = "7.0" # login ldap3 = { version = "0.10", default-features = false, features = ["tls-rustls"] } # storage -k2v-client = { git = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git", tag = "v0.9.1" } +k2v-client = { git = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git", branch = "k2v/shared_http_client" } aws-config = { version = "1", features = ["behavior-version-latest"] } aws-sdk-s3 = "1" aws-smithy-runtime = "1" diff --git a/src/login/ldap_provider.rs b/src/login/ldap_provider.rs index 42c993d..0af5676 100644 --- a/src/login/ldap_provider.rs +++ b/src/login/ldap_provider.rs @@ -96,7 +96,7 @@ impl LdapLoginProvider { //Login provider should return only a cryptoroot + a storage URI //storage URI that should be resolved outside... in_memory_store: storage::in_memory::MemDb::new(), - garage_store: storage::garage::GarageRoot::new(), + garage_store: storage::garage::GarageRoot::new()?, }) } diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs index e190a91..79626df 100644 --- a/src/login/static_provider.rs +++ b/src/login/static_provider.rs @@ -85,7 +85,7 @@ impl StaticLoginProvider { Ok(Self { user_db: rx, in_memory_store: storage::in_memory::MemDb::new(), - garage_store: storage::garage::GarageRoot::new(), + garage_store: storage::garage::GarageRoot::new()?, }) } } diff --git a/src/storage/garage.rs b/src/storage/garage.rs index 870854a..a23bbb2 100644 --- a/src/storage/garage.rs +++ b/src/storage/garage.rs @@ -1,27 +1,29 @@ -use crate::storage::*; use aws_sdk_s3::{self as s3, error::SdkError, operation::get_object::GetObjectError}; use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder; use aws_smithy_runtime_api::client::http::SharedHttpClient; -//use hyper_rustls::HttpsConnector; -//use hyper_util::client::legacy::connect::HttpConnector; - - +use hyper_rustls::HttpsConnector; +use hyper_util::rt::TokioExecutor; +use hyper_util::client::legacy::{connect::HttpConnector, Client as HttpClient}; use serde::Serialize; +use crate::storage::*; + pub struct GarageRoot { + k2v_http: HttpClient<HttpsConnector<HttpConnector>, k2v_client::Body>, aws_http: SharedHttpClient, } impl GarageRoot { - pub fn new() -> Self { - /*let http = hyper_rustls::HttpsConnectorBuilder::new() - .https_or_http() - .with_native_roots() - .enable_http1() - .enable_http2() - .build();*/ + pub fn new() -> anyhow::Result<Self> { + let connector = hyper_rustls::HttpsConnectorBuilder::new() + .with_native_roots()? + .https_or_http() + .enable_http1() + .enable_http2() + .build(); + let k2v_http = HttpClient::builder(TokioExecutor::new()).build(connector); let aws_http = HyperClientBuilder::new().build_https(); - Self { aws_http } + Ok(Self { k2v_http, aws_http }) } pub fn user(&self, conf: GarageConf) -> anyhow::Result<Arc<GarageUser>> { @@ -29,7 +31,12 @@ impl GarageRoot { unicity.extend_from_slice(file!().as_bytes()); unicity.append(&mut rmp_serde::to_vec(&conf)?); - Ok(Arc::new(GarageUser { conf, aws_http: self.aws_http.clone(), unicity })) + Ok(Arc::new(GarageUser { + conf, + aws_http: self.aws_http.clone(), + k2v_http: self.k2v_http.clone(), + unicity + })) } } @@ -50,6 +57,7 @@ pub struct GarageConf { pub struct GarageUser { conf: GarageConf, aws_http: SharedHttpClient, + k2v_http: HttpClient<HttpsConnector<HttpConnector>, k2v_client::Body>, unicity: Vec<u8>, } @@ -87,7 +95,7 @@ impl IBuilder for GarageUser { user_agent: None, }; - let k2v_client = match k2v_client::K2vClient::new(k2v_config) { + let k2v_client = match k2v_client::K2vClient::new_with_client(k2v_config, self.k2v_http.clone()) { Err(e) => { tracing::error!("unable to build k2v client: {}", e); return Err(StorageError::Internal); |