aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-02-23 17:01:51 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-02-23 17:01:51 +0100
commit02a8537556236437d905cefe8aa2c5d0a96f129a (patch)
tree823c209287b2bd5373bf941ea5362e7f97eb94f6
parenta579382042e0e1af95a00e97647a2cc3794fb108 (diff)
downloadaerogramme-02a8537556236437d905cefe8aa2c5d0a96f129a.tar.gz
aerogramme-02a8537556236437d905cefe8aa2c5d0a96f129a.zip
Replace with a single AWS HTTP client
-rw-r--r--Cargo.lock303
-rw-r--r--Cargo.toml7
-rw-r--r--src/login/ldap_provider.rs7
-rw-r--r--src/login/static_provider.rs6
-rw-r--r--src/storage/garage.rs49
5 files changed, 225 insertions, 147 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 45eaad3..9fdbd4b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -35,6 +35,8 @@ dependencies = [
"async-trait",
"aws-config",
"aws-sdk-s3",
+ "aws-smithy-runtime",
+ "aws-smithy-runtime-api",
"backtrace",
"base64 0.21.7",
"chrono",
@@ -45,6 +47,7 @@ dependencies = [
"futures",
"hex",
"hyper-rustls",
+ "hyper-util",
"im",
"imap-codec",
"imap-flow",
@@ -455,28 +458,27 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "aws-config"
-version = "1.1.2"
+version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e64b72d4bdbb41a73d27709c65a25b6e4bfc8321bf70fa3a8b19ce7d4eb81b0"
+checksum = "3182c19847238b50b62ae0383a6dbfc14514e552eb5e307e1ea83ccf5840b8a6"
dependencies = [
"aws-credential-types",
- "aws-http",
"aws-runtime",
"aws-sdk-sso",
"aws-sdk-ssooidc",
"aws-sdk-sts",
"aws-smithy-async",
- "aws-smithy-http 0.60.3",
+ "aws-smithy-http 0.60.6",
"aws-smithy-json",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"aws-types",
"bytes",
"fastrand 2.0.1",
"hex",
- "http",
- "hyper",
+ "http 0.2.11",
+ "hyper 0.14.28",
"ring 0.17.7",
"time",
"tokio",
@@ -486,77 +488,62 @@ dependencies = [
[[package]]
name = "aws-credential-types"
-version = "1.1.2"
+version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a7cb3510b95492bd9014b60e2e3bee3e48bc516e220316f8e6b60df18b47331"
+checksum = "e5635d8707f265c773282a22abe1ecd4fbe96a8eb2f0f14c0796f8016f11a41a"
dependencies = [
"aws-smithy-async",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"zeroize",
]
[[package]]
-name = "aws-http"
-version = "0.60.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a95d41abe4e941399fdb4bc2f54713eac3c839d98151875948bb24e66ab658f2"
-dependencies = [
- "aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
- "aws-types",
- "bytes",
- "http",
- "http-body",
- "pin-project-lite 0.2.13",
- "tracing",
-]
-
-[[package]]
name = "aws-runtime"
-version = "1.1.2"
+version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "233cca219c6705d525ace011d6f9bc51aaf32fce5b4c41661d2d7ff22d9b4d49"
+checksum = "6f82b9ae2adfd9d6582440d0eeb394c07f74d21b4c0cc72bdb73735c9e1a9c0e"
dependencies = [
"aws-credential-types",
- "aws-http",
- "aws-sigv4 1.1.2",
+ "aws-sigv4 1.1.6",
"aws-smithy-async",
"aws-smithy-eventstream",
- "aws-smithy-http 0.60.3",
+ "aws-smithy-http 0.60.6",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"aws-types",
+ "bytes",
"fastrand 2.0.1",
- "http",
+ "http 0.2.11",
+ "http-body 0.4.6",
"percent-encoding",
+ "pin-project-lite 0.2.13",
"tracing",
"uuid",
]
[[package]]
name = "aws-sdk-s3"
-version = "1.12.0"
+version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "634fbe5b6591ee2e281cd2ba8641e9bd752dbf5bf338924d6ad4bd5a3304fe31"
+checksum = "5076637347e7d0218e61facae853110682ae58efabd2f4e2a9e530c203d5fa7b"
dependencies = [
"aws-credential-types",
- "aws-http",
"aws-runtime",
- "aws-sigv4 1.1.2",
+ "aws-sigv4 1.1.6",
"aws-smithy-async",
"aws-smithy-checksums",
"aws-smithy-eventstream",
- "aws-smithy-http 0.60.3",
+ "aws-smithy-http 0.60.6",
"aws-smithy-json",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"aws-smithy-xml",
"aws-types",
"bytes",
- "http",
- "http-body",
+ "http 0.2.11",
+ "http-body 0.4.6",
"once_cell",
"percent-encoding",
"regex-lite",
@@ -566,22 +553,21 @@ dependencies = [
[[package]]
name = "aws-sdk-sso"
-version = "1.10.0"
+version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee41005e0f3a19ae749c7953d9e1f1ef8d2183f76f64966e346fa41c1ba0ed44"
+checksum = "ca7e8097448832fcd22faf6bb227e97d76b40e354509d1307653a885811c7151"
dependencies = [
"aws-credential-types",
- "aws-http",
"aws-runtime",
"aws-smithy-async",
- "aws-smithy-http 0.60.3",
+ "aws-smithy-http 0.60.6",
"aws-smithy-json",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"aws-types",
"bytes",
- "http",
+ "http 0.2.11",
"once_cell",
"regex-lite",
"tracing",
@@ -589,22 +575,21 @@ dependencies = [
[[package]]
name = "aws-sdk-ssooidc"
-version = "1.10.0"
+version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa08168f8a27505e7b90f922c32a489feb1f2133878981a15138bebc849ac09c"
+checksum = "a75073590e23d63044606771afae309fada8eb10ded54a1ce4598347221d3fef"
dependencies = [
"aws-credential-types",
- "aws-http",
"aws-runtime",
"aws-smithy-async",
- "aws-smithy-http 0.60.3",
+ "aws-smithy-http 0.60.6",
"aws-smithy-json",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"aws-types",
"bytes",
- "http",
+ "http 0.2.11",
"once_cell",
"regex-lite",
"tracing",
@@ -612,23 +597,22 @@ dependencies = [
[[package]]
name = "aws-sdk-sts"
-version = "1.10.0"
+version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29102eff04d50ef70f11a48823db33e33c6cc5f027bfb6ff4864efbd5f1f66f3"
+checksum = "650e4aaae41547151dea4d8142f7ffcc8ab8ba76d5dccc8933936ef2102c3356"
dependencies = [
"aws-credential-types",
- "aws-http",
"aws-runtime",
"aws-smithy-async",
- "aws-smithy-http 0.60.3",
+ "aws-smithy-http 0.60.6",
"aws-smithy-json",
"aws-smithy-query",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"aws-smithy-xml",
"aws-types",
- "http",
+ "http 0.2.11",
"once_cell",
"regex-lite",
"tracing",
@@ -644,7 +628,7 @@ dependencies = [
"form_urlencoded",
"hex",
"hmac",
- "http",
+ "http 0.2.11",
"once_cell",
"percent-encoding",
"regex",
@@ -655,21 +639,22 @@ dependencies = [
[[package]]
name = "aws-sigv4"
-version = "1.1.2"
+version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b92384b39aedb258aa734fe0e7b2ffcd13f33e68227251a72cd2635e0acc8f1a"
+checksum = "404c64a104188ac70dd1684718765cb5559795458e446480e41984e68e57d888"
dependencies = [
"aws-credential-types",
"aws-smithy-eventstream",
- "aws-smithy-http 0.60.3",
+ "aws-smithy-http 0.60.6",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"bytes",
"crypto-bigint 0.5.5",
"form_urlencoded",
"hex",
"hmac",
- "http",
+ "http 0.2.11",
+ "http 1.0.0",
"once_cell",
"p256",
"percent-encoding",
@@ -683,9 +668,9 @@ dependencies = [
[[package]]
name = "aws-smithy-async"
-version = "1.1.3"
+version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2eac0bb78e9e2765699999a02d7bfb4e6ad8f13e0962ebb9f5202b1d8cd76006"
+checksum = "fcf7f09a27286d84315dfb9346208abb3b0973a692454ae6d0bc8d803fcce3b4"
dependencies = [
"futures-util",
"pin-project-lite 0.2.13",
@@ -694,18 +679,18 @@ dependencies = [
[[package]]
name = "aws-smithy-checksums"
-version = "0.60.3"
+version = "0.60.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "535a2d5f1e459bc7709580a77152c8d493982db083236c2b1d1c51dc6217e8a3"
+checksum = "0fd4b66f2a8e7c84d7e97bda2666273d41d2a2e25302605bcf906b7b2661ae5e"
dependencies = [
- "aws-smithy-http 0.60.3",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-http 0.60.6",
+ "aws-smithy-types 1.1.7",
"bytes",
"crc32c",
"crc32fast",
"hex",
- "http",
- "http-body",
+ "http 0.2.11",
+ "http-body 0.4.6",
"md-5",
"pin-project-lite 0.2.13",
"sha1",
@@ -715,11 +700,11 @@ dependencies = [
[[package]]
name = "aws-smithy-eventstream"
-version = "0.60.3"
+version = "0.60.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "682371561562d08ab437766903c6bc28f4f95d7ab2ecfb389bda7849dd98aefe"
+checksum = "e6363078f927f612b970edf9d1903ef5cef9a64d1e8423525ebb1f0a1633c858"
dependencies = [
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"bytes",
"crc32fast",
]
@@ -734,9 +719,9 @@ dependencies = [
"bytes",
"bytes-utils",
"futures-core",
- "http",
- "http-body",
- "hyper",
+ "http 0.2.11",
+ "http-body 0.4.6",
+ "hyper 0.14.28",
"once_cell",
"percent-encoding",
"pin-project-lite 0.2.13",
@@ -746,18 +731,18 @@ dependencies = [
[[package]]
name = "aws-smithy-http"
-version = "0.60.3"
+version = "0.60.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "365ca49744b2bda2f1e2dc03b856da3fa5a28ca5b0a41e41d7ff5305a8fae190"
+checksum = "b6ca214a6a26f1b7ebd63aa8d4f5e2194095643023f9608edf99a58247b9d80d"
dependencies = [
"aws-smithy-eventstream",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"bytes",
"bytes-utils",
"futures-core",
- "http",
- "http-body",
+ "http 0.2.11",
+ "http-body 0.4.6",
"once_cell",
"percent-encoding",
"pin-project-lite 0.2.13",
@@ -767,39 +752,39 @@ dependencies = [
[[package]]
name = "aws-smithy-json"
-version = "0.60.3"
+version = "0.60.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "733ccdb727ac63370836aa3b3c483d75ad2ef7bc6507db3efe1d01e8d2e50367"
+checksum = "1af80ecf3057fb25fe38d1687e94c4601a7817c6a1e87c1b0635f7ecb644ace5"
dependencies = [
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
]
[[package]]
name = "aws-smithy-query"
-version = "0.60.3"
+version = "0.60.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aff02ae2ee7968bbce2983ffb5ce529d24f4848532300f398347bde8c2196974"
+checksum = "eb27084f72ea5fc20033efe180618677ff4a2f474b53d84695cfe310a6526cbc"
dependencies = [
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"urlencoding",
]
[[package]]
name = "aws-smithy-runtime"
-version = "1.1.3"
+version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ab9cb6fee50680af8ceaa293ae79eba32095ca117161cb323f9ee30dd87d139"
+checksum = "fbb5fca54a532a36ff927fbd7407a7c8eb9c3b4faf72792ba2965ea2cad8ed55"
dependencies = [
"aws-smithy-async",
- "aws-smithy-http 0.60.3",
+ "aws-smithy-http 0.60.6",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"bytes",
"fastrand 2.0.1",
"h2",
- "http",
- "http-body",
- "hyper",
+ "http 0.2.11",
+ "http-body 0.4.6",
+ "hyper 0.14.28",
"hyper-rustls",
"once_cell",
"pin-project-lite 0.2.13",
@@ -811,14 +796,15 @@ dependencies = [
[[package]]
name = "aws-smithy-runtime-api"
-version = "1.1.3"
+version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "02ca2da7619517310bfead6d18abcdde90f1439224d887d608503cfacff46dff"
+checksum = "22389cb6f7cac64f266fb9f137745a9349ced7b47e0d2ba503e9e40ede4f7060"
dependencies = [
"aws-smithy-async",
- "aws-smithy-types 1.1.3",
+ "aws-smithy-types 1.1.7",
"bytes",
- "http",
+ "http 0.2.11",
+ "http 1.0.0",
"pin-project-lite 0.2.13",
"tokio",
"tracing",
@@ -840,16 +826,16 @@ dependencies = [
[[package]]
name = "aws-smithy-types"
-version = "1.1.3"
+version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d4bb944488536cd2fef43212d829bc7e9a8bfc4afa079d21170441e7be8d2d0"
+checksum = "f081da5481210523d44ffd83d9f0740320050054006c719eae0232d411f024d3"
dependencies = [
"base64-simd",
"bytes",
"bytes-utils",
"futures-core",
- "http",
- "http-body",
+ "http 0.2.11",
+ "http-body 0.4.6",
"itoa",
"num-integer",
"pin-project-lite 0.2.13",
@@ -863,24 +849,24 @@ dependencies = [
[[package]]
name = "aws-smithy-xml"
-version = "0.60.3"
+version = "0.60.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef796feaf894d7fd03869235237aeffe73ed1b29a3927cceeee2eecadf876eba"
+checksum = "0fccd8f595d0ca839f9f2548e66b99514a85f92feb4c01cf2868d93eb4888a42"
dependencies = [
"xmlparser",
]
[[package]]
name = "aws-types"
-version = "1.1.2"
+version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8549aa62c5b7db5c57ab915200ee214b4f5d8f19b29a4a8fa0b3ad3bca1380e3"
+checksum = "8fbb5d48aae496f628e7aa2e41991dd4074f606d9e3ade1ce1059f293d40f9a2"
dependencies = [
"aws-credential-types",
"aws-smithy-async",
"aws-smithy-runtime-api",
- "aws-smithy-types 1.1.3",
- "http",
+ "aws-smithy-types 1.1.7",
+ "http 0.2.11",
"rustc_version",
"tracing",
]
@@ -896,9 +882,9 @@ dependencies = [
"bitflags 1.3.2",
"bytes",
"futures-util",
- "http",
- "http-body",
- "hyper",
+ "http 0.2.11",
+ "http-body 0.4.6",
+ "hyper 0.14.28",
"itoa",
"matchit",
"memchr",
@@ -922,8 +908,8 @@ dependencies = [
"async-trait",
"bytes",
"futures-util",
- "http",
- "http-body",
+ "http 0.2.11",
+ "http-body 0.4.6",
"mime",
"rustversion",
"tower-layer",
@@ -1242,9 +1228,9 @@ dependencies = [
[[package]]
name = "crc32c"
-version = "0.6.4"
+version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d8f48d60e5b4d2c53d5c2b1d8a58c849a70ae5e5509b08a48d047e3b65714a74"
+checksum = "89254598aa9b9fa608de44b3ae54c810f0f06d755e24c50177f1f8f31ff50ce2"
dependencies = [
"rustc_version",
]
@@ -1743,7 +1729,7 @@ dependencies = [
"futures-core",
"futures-sink",
"futures-util",
- "http",
+ "http 0.2.11",
"indexmap 2.1.0",
"slab",
"tokio",
@@ -1824,17 +1810,38 @@ dependencies = [
]
[[package]]
+name = "http"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea"
+dependencies = [
+ "bytes",
+ "fnv",
+ "itoa",
+]
+
+[[package]]
name = "http-body"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [
"bytes",
- "http",
+ "http 0.2.11",
"pin-project-lite 0.2.13",
]
[[package]]
+name = "http-body"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
+dependencies = [
+ "bytes",
+ "http 1.0.0",
+]
+
+[[package]]
name = "httparse"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1863,13 +1870,13 @@ dependencies = [
"futures-core",
"futures-util",
"h2",
- "http",
- "http-body",
+ "http 0.2.11",
+ "http-body 0.4.6",
"httparse",
"httpdate",
"itoa",
"pin-project-lite 0.2.13",
- "socket2 0.4.10",
+ "socket2 0.5.5",
"tokio",
"tower-service",
"tracing",
@@ -1877,14 +1884,29 @@ dependencies = [
]
[[package]]
+name = "hyper"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a"
+dependencies = [
+ "bytes",
+ "http 1.0.0",
+ "http-body 1.0.0",
+ "pin-project-lite 0.2.13",
+ "smallvec",
+ "tokio",
+ "want",
+]
+
+[[package]]
name = "hyper-rustls"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
dependencies = [
"futures-util",
- "http",
- "hyper",
+ "http 0.2.11",
+ "hyper 0.14.28",
"log",
"rustls 0.21.10",
"rustls-native-certs",
@@ -1898,13 +1920,31 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
dependencies = [
- "hyper",
+ "hyper 0.14.28",
"pin-project-lite 0.2.13",
"tokio",
"tokio-io-timeout",
]
[[package]]
+name = "hyper-util"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-util",
+ "http 1.0.0",
+ "http-body 1.0.0",
+ "hyper 1.2.0",
+ "pin-project-lite 0.2.13",
+ "tower",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
name = "iana-time-zone"
version = "0.1.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2083,8 +2123,8 @@ dependencies = [
"aws-sigv4 0.55.3",
"base64 0.21.7",
"hex",
- "http",
- "hyper",
+ "http 0.2.11",
+ "hyper 0.14.28",
"hyper-rustls",
"log",
"percent-encoding",
@@ -3523,9 +3563,9 @@ dependencies = [
"base64 0.21.7",
"bytes",
"h2",
- "http",
- "http-body",
- "hyper",
+ "http 0.2.11",
+ "http-body 0.4.6",
+ "hyper 0.14.28",
"hyper-timeout",
"percent-encoding",
"pin-project",
@@ -3576,6 +3616,7 @@ version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [
+ "log",
"pin-project-lite 0.2.13",
"tracing-attributes",
"tracing-core",
diff --git a/Cargo.toml b/Cargo.toml
index aad2ac6..48d1db4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -49,6 +49,7 @@ 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"] }
rpassword = "7.0"
# login
@@ -56,8 +57,10 @@ 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" }
-aws-config = { version = "1.1.1", features = ["behavior-version-latest"] }
-aws-sdk-s3 = "1.9.0"
+aws-config = { version = "1", features = ["behavior-version-latest"] }
+aws-sdk-s3 = "1"
+aws-smithy-runtime = "1"
+aws-smithy-runtime-api = "1"
# email protocols
eml-codec = "0.1.2"
diff --git a/src/login/ldap_provider.rs b/src/login/ldap_provider.rs
index e73e1dc..42c993d 100644
--- a/src/login/ldap_provider.rs
+++ b/src/login/ldap_provider.rs
@@ -21,6 +21,7 @@ pub struct LdapLoginProvider {
storage_specific: StorageSpecific,
in_memory_store: storage::in_memory::MemDb,
+ garage_store: storage::garage::GarageRoot,
}
enum BucketSource {
@@ -91,7 +92,11 @@ impl LdapLoginProvider {
mail_attr: config.mail_attr,
crypto_root_attr: config.crypto_root_attr,
storage_specific: specific,
+ //@FIXME should be created outside of the login provider
+ //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(),
})
}
@@ -114,7 +119,7 @@ impl LdapLoginProvider {
BucketSource::Attr(a) => get_attr(user, &a)?,
};
- storage::garage::GarageBuilder::new(storage::garage::GarageConf {
+ self.garage_store.user(storage::garage::GarageConf {
region: from_config.aws_region.clone(),
s3_endpoint: from_config.s3_endpoint.clone(),
k2v_endpoint: from_config.k2v_endpoint.clone(),
diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs
index 1e1ecbf..e190a91 100644
--- a/src/login/static_provider.rs
+++ b/src/login/static_provider.rs
@@ -25,6 +25,7 @@ pub struct UserDatabase {
pub struct StaticLoginProvider {
user_db: watch::Receiver<UserDatabase>,
in_memory_store: storage::in_memory::MemDb,
+ garage_store: storage::garage::GarageRoot,
}
pub async fn update_user_list(config: PathBuf, up: watch::Sender<UserDatabase>) -> Result<()> {
@@ -84,6 +85,7 @@ impl StaticLoginProvider {
Ok(Self {
user_db: rx,
in_memory_store: storage::in_memory::MemDb::new(),
+ garage_store: storage::garage::GarageRoot::new(),
})
}
}
@@ -109,7 +111,7 @@ impl LoginProvider for StaticLoginProvider {
let storage: storage::Builder = match &user.config.storage {
StaticStorage::InMemory => self.in_memory_store.builder(username).await,
StaticStorage::Garage(grgconf) => {
- storage::garage::GarageBuilder::new(storage::garage::GarageConf {
+ self.garage_store.user(storage::garage::GarageConf {
region: grgconf.aws_region.clone(),
k2v_endpoint: grgconf.k2v_endpoint.clone(),
s3_endpoint: grgconf.s3_endpoint.clone(),
@@ -140,7 +142,7 @@ impl LoginProvider for StaticLoginProvider {
let storage: storage::Builder = match &user.config.storage {
StaticStorage::InMemory => self.in_memory_store.builder(&user.username).await,
StaticStorage::Garage(grgconf) => {
- storage::garage::GarageBuilder::new(storage::garage::GarageConf {
+ self.garage_store.user(storage::garage::GarageConf {
region: grgconf.aws_region.clone(),
k2v_endpoint: grgconf.k2v_endpoint.clone(),
s3_endpoint: grgconf.s3_endpoint.clone(),
diff --git a/src/storage/garage.rs b/src/storage/garage.rs
index 709e729..870854a 100644
--- a/src/storage/garage.rs
+++ b/src/storage/garage.rs
@@ -1,7 +1,38 @@
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 serde::Serialize;
+pub struct GarageRoot {
+ 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();*/
+ let aws_http = HyperClientBuilder::new().build_https();
+ Self { aws_http }
+ }
+
+ pub fn user(&self, conf: GarageConf) -> anyhow::Result<Arc<GarageUser>> {
+ let mut unicity: Vec<u8> = vec![];
+ 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 }))
+ }
+}
+
#[derive(Clone, Debug, Serialize)]
pub struct GarageConf {
pub region: String,
@@ -12,23 +43,18 @@ pub struct GarageConf {
pub bucket: String,
}
+//@FIXME we should get rid of this builder
+//and allocate a S3 + K2V client only once per user
+//(and using a shared HTTP client)
#[derive(Clone, Debug)]
-pub struct GarageBuilder {
+pub struct GarageUser {
conf: GarageConf,
+ aws_http: SharedHttpClient,
unicity: Vec<u8>,
}
-impl GarageBuilder {
- pub fn new(conf: GarageConf) -> anyhow::Result<Arc<Self>> {
- let mut unicity: Vec<u8> = vec![];
- unicity.extend_from_slice(file!().as_bytes());
- unicity.append(&mut rmp_serde::to_vec(&conf)?);
- Ok(Arc::new(Self { conf, unicity }))
- }
-}
-
#[async_trait]
-impl IBuilder for GarageBuilder {
+impl IBuilder for GarageUser {
async fn build(&self) -> Result<Store, StorageError> {
let s3_creds = s3::config::Credentials::new(
self.conf.aws_access_key_id.clone(),
@@ -41,6 +67,7 @@ impl IBuilder for GarageBuilder {
let sdk_config = aws_config::from_env()
.region(aws_config::Region::new(self.conf.region.clone()))
.credentials_provider(s3_creds)
+ .http_client(self.aws_http.clone())
.endpoint_url(self.conf.s3_endpoint.clone())
.load()
.await;