diff --git a/Cargo.lock b/Cargo.lock index d3d1225..7f1bde4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -245,6 +245,21 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -307,6 +322,274 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "aws-credential-types" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51fd637c25fe0a09b1079be1518f61b3532e9812516aa50f1723303aef8a10c6" +dependencies = [ + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "zeroize", +] + +[[package]] +name = "aws-http" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d6b5356f29ecdac88f82153b66e77260a4c1a58fad93c465714ed42416a0f83" +dependencies = [ + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http", + "http-body", + "pin-project-lite", + "tracing", +] + +[[package]] +name = "aws-runtime" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6d61ac3425f2bd1d69393b96569a7408467f8927a5cfeba597b19f78ebb185" +dependencies = [ + "aws-credential-types", + "aws-http", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "fastrand", + "http", + "percent-encoding", + "tracing", + "uuid", +] + +[[package]] +name = "aws-sdk-s3" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693ff3ba604fa0db18799fb770c7cde5c3e9302a7b7644647c4e46a615b96e23" +dependencies = [ + "aws-credential-types", + "aws-http", + "aws-runtime", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-checksums", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "bytes", + "http", + "http-body", + "once_cell", + "percent-encoding", + "regex-lite", + "tracing", + "url", +] + +[[package]] +name = "aws-sigv4" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f39bf5bfa061fd1487a7ba274927dd6d70feed5cecaf3367932bcc83148d8f" +dependencies = [ + "aws-credential-types", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "crypto-bigint 0.5.5", + "form_urlencoded", + "hex", + "hmac", + "http", + "once_cell", + "p256", + "percent-encoding", + "ring", + "sha2", + "subtle", + "time", + "tracing", + "zeroize", +] + +[[package]] +name = "aws-smithy-async" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8251646e230593f141a6df2421f5c9cebae4b7b5f874482164ccc9885a662b5d" +dependencies = [ + "futures-util", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "aws-smithy-checksums" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3c4fd37c10269ad70de25cfbe29f52c1ae6fc48606a2b1ed2c4bdeb624d5da9" +dependencies = [ + "aws-smithy-http", + "aws-smithy-types", + "bytes", + "crc32c", + "crc32fast", + "hex", + "http", + "http-body", + "md-5", + "pin-project-lite", + "sha1", + "sha2", + "tracing", +] + +[[package]] +name = "aws-smithy-eventstream" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af68fac4c4b0046f94fe2d9332c9b992cebcb47cb42017f79df12ed7958ebd01" +dependencies = [ + "aws-smithy-types", + "bytes", + "crc32fast", +] + +[[package]] +name = "aws-smithy-http" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e68d7a4a9b8be1342066dd8b26c925e79f4e399a7e57ee22f9d162eb041d592" +dependencies = [ + "aws-smithy-eventstream", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http", + "http-body", + "once_cell", + "percent-encoding", + "pin-project-lite", + "pin-utils", + "tracing", +] + +[[package]] +name = "aws-smithy-json" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50877200c8d382b728631e9abe6556abc9830b1aa9c1e7b3e16f64bdbfb86a89" +dependencies = [ + "aws-smithy-types", +] + +[[package]] +name = "aws-smithy-runtime" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8c54dd9c5a159013f1e6885cb7c1ae8fc98dc286d2aebe71737effef28e37" +dependencies = [ + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "fastrand", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "once_cell", + "pin-project-lite", + "pin-utils", + "rustls", + "tokio", + "tracing", +] + +[[package]] +name = "aws-smithy-runtime-api" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55ed8f64f72162056db15e05394e9aa2b5a58a0b5ebeab5694f9a463b79bea8" +dependencies = [ + "aws-smithy-async", + "aws-smithy-types", + "bytes", + "http", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "aws-smithy-types" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6d0b5ba0f92811d45954c61e3ada057d2a09ee0357403cf86ece562e5fa8268" +dependencies = [ + "base64-simd", + "bytes", + "bytes-utils", + "futures-core", + "http", + "http-body", + "itoa", + "num-integer", + "pin-project-lite", + "pin-utils", + "ryu", + "serde", + "time", + "tokio", + "tokio-util", +] + +[[package]] +name = "aws-smithy-xml" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8085dd62bd9dc6ecdd2ef74d8420ac3101595d31977f280fb42325a08ecdeab" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "aws-types" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bb5cb4613a226634140ac27dc36a8af6043dd84e92b50d0d6fde72a0e10004" +dependencies = [ + "aws-credential-types", + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "http", + "rustc_version", + "tracing", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -322,6 +605,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.13.1" @@ -334,6 +623,22 @@ version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +[[package]] +name = "base64-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" +dependencies = [ + "outref", + "vsimd", +] + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "base64urlsafedata" version = "0.1.2" @@ -399,6 +704,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +[[package]] +name = "bytes-utils" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dafe3a8757b027e2be6e4e5601ed563c55989fcf1546e933c66c8eb3a058d35" +dependencies = [ + "bytes", + "either", +] + [[package]] name = "bytestring" version = "1.3.0" @@ -410,11 +725,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.78" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -423,6 +739,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets", +] + [[package]] name = "clap" version = "4.0.29" @@ -460,6 +791,16 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "compact_jwt" version = "0.2.9" @@ -477,6 +818,12 @@ dependencies = [ "uuid", ] +[[package]] +name = "const-oid" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + [[package]] name = "convert_case" version = "0.4.0" @@ -494,6 +841,22 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpufeatures" version = "0.2.5" @@ -503,6 +866,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32c" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8f48d60e5b4d2c53d5c2b1d8a58c849a70ae5e5509b08a48d047e3b65714a74" +dependencies = [ + "rustc_version", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -512,6 +884,28 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "rand_core", + "subtle", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -522,6 +916,50 @@ dependencies = [ "typenum", ] +[[package]] +name = "cxx" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88abab2f5abbe4c56e8f1fb431b784d710b709888f35755a160e62e33fe38e8" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c0c11acd0e63bae27dcd2afced407063312771212b7a823b4fd72d633be30fb" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn 2.0.37", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3816ed957c008ccd4728485511e3d9aaf7db419aa321e3d2c5a2f3411e36c8" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26acccf6f445af85ea056362561a24ef56cdc15fcc685f03aec50b9c702cb6d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + [[package]] name = "data-encoding" version = "2.3.3" @@ -561,6 +999,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "der-parser" version = "7.0.0" @@ -590,9 +1038,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -610,6 +1058,44 @@ dependencies = [ "syn 1.0.107", ] +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint 0.4.9", + "der", + "digest", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "encoding_rs" version = "0.8.32" @@ -652,6 +1138,22 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + [[package]] name = "finl_unicode" version = "1.2.0" @@ -764,9 +1266,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", @@ -780,10 +1282,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] -name = "h2" -version = "0.3.15" +name = "group" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -791,7 +1304,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.2", + "indexmap", "slab", "tokio", "tokio-util", @@ -818,12 +1331,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.14.1" @@ -871,15 +1378,26 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" 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", + "pin-project-lite", +] + [[package]] name = "httparse" version = "1.8.0" @@ -892,6 +1410,70 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.4.9", + "tokio", + "tower-service", + "tracing", + "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", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "idna" version = "0.3.0" @@ -902,16 +1484,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.0.2" @@ -919,7 +1491,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown", ] [[package]] @@ -982,9 +1554,18 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "link-cplusplus" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" +dependencies = [ + "cc", +] [[package]] name = "linux-raw-sys" @@ -1093,6 +1674,8 @@ version = "0.1.0" dependencies = [ "actix-web", "anyhow", + "aws-sdk-s3", + "chrono", "clap", "deadpool-postgres", "handlebars", @@ -1168,9 +1751,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.16.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" @@ -1198,6 +1781,12 @@ dependencies = [ "syn 1.0.107", ] +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + [[package]] name = "openssl-sys" version = "0.9.80" @@ -1217,6 +1806,23 @@ version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +[[package]] +name = "outref" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" + +[[package]] +name = "p256" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sha2", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -1326,6 +1932,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.26" @@ -1369,6 +1985,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d2234cdee9408b523530a9b6d2d6b373d1db34f6a8e51dc03ded1828d7fb67c" dependencies = [ "bytes", + "chrono", "fallible-iterator", "postgres-derive", "postgres-protocol", @@ -1532,12 +2149,43 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-lite" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" + [[package]] name = "regex-syntax" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint 0.4.9", + "hmac", + "zeroize", +] + +[[package]] +name = "ring" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.48.0", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1576,6 +2224,49 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "rustls" +version = "0.21.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.2", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "ryu" version = "1.0.12" @@ -1591,12 +2282,74 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.17" @@ -1696,6 +2449,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest", + "rand_core", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -1743,6 +2506,22 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stringprep" version = "0.1.4" @@ -1762,9 +2541,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -1928,6 +2707,16 @@ dependencies = [ "whoami", ] +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.4" @@ -1969,13 +2758,19 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap", "serde", "serde_spanned", "toml_datetime", "winnow", ] +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -2009,6 +2804,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.16.0" @@ -2042,12 +2843,24 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + [[package]] name = "unicode-xid" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.3.1" @@ -2082,6 +2895,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + [[package]] name = "walkdir" version = "2.4.0" @@ -2092,6 +2911,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2253,6 +3081,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -2403,6 +3240,18 @@ dependencies = [ "time", ] +[[package]] +name = "xmlparser" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + [[package]] name = "zstd" version = "0.12.3+zstd.1.5.2" diff --git a/Cargo.toml b/Cargo.toml index fef6937..bb58c4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,11 +15,13 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" handlebars = "4.3.6" deadpool-postgres = "0.11.0" -tokio-postgres = { version = "0.7.10", features = ["with-uuid-1", "with-serde_json-1"] } +tokio-postgres = { version = "0.7.10", features = ["with-uuid-1", "with-serde_json-1", "with-chrono-0_4"] } postgres-types = { version = "*", features = ["derive"] } anyhow = "1.0.75" refinery = { version = "0.8.11", features = ["tokio-postgres"] } uuid = { version = "1.4.1", features = ["v4"] } +chrono = { version = "*", features = ["serde"] } +aws-sdk-s3 = "1.6.0" [dependencies.heck] version = "0.4.1" diff --git a/default.nix b/default.nix index df8ae04..3feb0e9 100644 --- a/default.nix +++ b/default.nix @@ -10,5 +10,5 @@ pkgs.rustPlatform.buildRustPackage { ]; buildInputs = [ pkgs.openssl ]; src = pkgs.lib.cleanSource ./.; - cargoHash = "sha256-0891xprAumfRvODg0Al6PnQ0EfWNgX+VUINjbutFilg="; + cargoHash = "sha256-ct90VmvzUIJ8d0LO7jz5/kcC3M0rU85DbX81/67T2R4="; } diff --git a/migrations/V1__init.sql b/migrations/V1__init.sql index ce64bb6..2feacad 100644 --- a/migrations/V1__init.sql +++ b/migrations/V1__init.sql @@ -22,7 +22,8 @@ CREATE TABLE BinaryCaches ( name text NOT NULL, access_key text NOT NULL, secret_key text NOT NULL, - region text NOT NULL + region text NOT NULL, + endpoint text NOT NULL ); CREATE TABLE Projects ( @@ -44,8 +45,11 @@ CREATE TABLE Closures ( id SERIAL PRIMARY KEY NOT NULL, project_id integer NOT NULL, objects text[] NOT NULL, + date timestamp NOT NULL, CONSTRAINT fk_project_closure FOREIGN KEY (project_id) REFERENCES Projects(id) ); -- We'll mostly querying the Keys using the associated uid. CREATE INDEX idx_keys_uid ON Keys USING HASH (user_id); +-- We'll be often sorting Closures through their datetime. +CREATE INDEX idx_date_closures ON Closures USING HASH (date); diff --git a/pg_dump b/pg_dump new file mode 100755 index 0000000..0267396 --- /dev/null +++ b/pg_dump @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +source /tmp/nom-nom-dev-args +pg_dump -h "${host}" -p "${port}" -d "${dbname}" > dump.sql diff --git a/psql b/psql index c4f3f8b..f15ce6d 100755 --- a/psql +++ b/psql @@ -1,4 +1,4 @@ #!/usr/bin/env bash source /tmp/nom-nom-dev-args -psql -h "${host}" -p "${port}" -d "${dbname}" +psql -h "${host}" -p "${port}" -d "${dbname}" "$@" diff --git a/run-dev-server b/run-dev-server index 526eb68..922233b 100755 --- a/run-dev-server +++ b/run-dev-server @@ -12,6 +12,7 @@ trap 'rm -rf ${dbdir}' EXIT initdb "$dbdir" postgres -D "${dbdir}" -c unix_socket_directories="${dbdir}" -c listen_addresses= -c port="${port}" & pgpid=$! + # Trick to help the "./psql" script to find the DB dir & co cat < "/tmp/nom-nom-dev-args" export host="$dbdir" @@ -23,7 +24,7 @@ EOF trap 'rm -rf ${dbdir} && rm /tmp/nom-nom-dev-args && kill ${pgpid}' EXIT # Yeah, this is very meh. We need to wait for the server to be ready -#to receive requests to create the DB. +# to receive requests to create the DB. sleep 2 createdb -h "${dbdir}" -p "${port}" "${dbname}" @@ -36,4 +37,12 @@ cat < "${cfgfile}" } EOF +# Check if there's a dump to seed the DB. +if [ -f dump.sql ]; then + echo "" + echo "[+] Seeding the DB with dump.sql" + echo "" + ./psql -f dump.sql +fi + cargo run --bin nom-nom-gc-server -- --bind "[::1]:8001" --config "${cfgfile}" diff --git a/src/handlers/binary_cache.rs b/src/handlers/binary_cache.rs new file mode 100644 index 0000000..b6644e2 --- /dev/null +++ b/src/handlers/binary_cache.rs @@ -0,0 +1,33 @@ +use actix_web::{web::{self, Form}, HttpResponse, http::header::{ContentType, self}, Responder, HttpRequest}; + +use crate::{models::{AppState, BinaryCache}, templates}; + +use super::check_authentication; + + +pub async fn new_binary_cache(app_state: web::Data>, req: HttpRequest) -> impl Responder { + if check_authentication(&app_state, req).await.is_ok() { + let response = templates::new_binary_cache(app_state.hbs.clone()).unwrap(); + HttpResponse::Ok() + .content_type(ContentType::html()) + .body(response) + } else { + HttpResponse::SeeOther() + .content_type(ContentType::plaintext()) + .append_header((header::LOCATION, "/login")) + .body("please log in") + } +} + +pub async fn new_binary_cache_post(app_state: web::Data>, req: HttpRequest, form: Form) -> impl Responder { + if check_authentication(&app_state, req).await.is_ok() { + app_state.create_binary_cache(&form).await.unwrap(); + HttpResponse::SeeOther() + .content_type(ContentType::plaintext()) + .append_header((header::LOCATION, "/")) + .body("new binary cache created") + } else { + HttpResponse::Forbidden() + .finish() + } +} diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 1245058..de47bd6 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -1,15 +1,31 @@ use actix_web::{HttpResponse, http::header::{ContentType, self}, web, HttpRequest, cookie::{Cookie, SameSite}}; +use chrono::Local; use uuid::Uuid; -use crate::{models::{AppState, SessionUuid, User}, templates}; +use crate::{models::{AppState, SessionUuid, User, ProjectSummary}, templates}; pub mod authentication; +pub mod binary_cache; pub use authentication::*; +pub use binary_cache::*; -pub async fn landing_page (app_state: web::Data>, req: HttpRequest) -> HttpResponse { +pub async fn landing_page (app_state: web::Data>) -> HttpResponse { + let summaries: Vec = vec![ + ProjectSummary { + name: "Test Project".to_string(), + latest_closure: "/nix/store/blabla".to_string(), + latest_closure_datetime: Local::now(), + } + ]; + let content: String = templates::landing_page(app_state.hbs.clone(), true, summaries).unwrap(); + HttpResponse::Ok() + .content_type(ContentType::html()) + .body(content) + /* match check_authentication(app_state.clone(), req).await { Ok(_) => { + let content: String = templates::landing_page(app_state.hbs.clone(), true).unwrap(); HttpResponse::Ok() .content_type(ContentType::html()) @@ -17,13 +33,14 @@ pub async fn landing_page (app_state: web::Data>, req: HttpRequest) }, Err(redirect) => redirect, } + */ } /** Checks if the user requesting the page is authenticated. */ -async fn check_authentication(app_state: web::Data>, req: HttpRequest) -> Result { +async fn check_authentication(app_state: &web::Data>, req: HttpRequest) -> Result { fn redirect_to_login(e: T, req: &HttpRequest) -> HttpResponse where T: ToString diff --git a/src/models/mod.rs b/src/models/mod.rs index 7f2a908..9d7abb5 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; use std::fs; use std::ops::DerefMut; use std::sync::Arc; +use chrono::{DateTime, Local}; use postgres_types::{FromSql, ToSql}; use url::Url; @@ -84,12 +85,13 @@ pub struct Key { pub key: Passkey } -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Deserialize)] pub struct BinaryCache { pub name: String, pub access_key: String, pub secret_key: String, - pub region: String + pub region: String, + pub endpoint: String } #[derive(Clone, Debug, Eq, PartialEq)] @@ -97,6 +99,13 @@ pub struct Project { pub name: String, } +#[derive(Serialize, Clone, Debug, Eq, PartialEq)] +pub struct ProjectSummary { + pub name: String, + pub latest_closure: String, + pub latest_closure_datetime: DateTime +} + impl AppState<'_> { pub fn new(conf: Configuration) -> Self { let rp = "localhost"; @@ -188,8 +197,8 @@ impl AppState<'_> { pub async fn create_binary_cache(&self, binary_cache: &BinaryCache) -> Result<()> { let conn = self.db.get().await?; - let stmt = conn.prepare_cached("INSERT INTO BinaryCaches (name, access_key, secret_key, region) VALUES ($1, $2, $3, $4)").await?; - let _ = conn.execute(&stmt, &[&binary_cache.name, &binary_cache.access_key, &binary_cache.secret_key, &binary_cache.region]).await?; + let stmt = conn.prepare_cached("INSERT INTO BinaryCaches (name, access_key, secret_key, region, endpoint) VALUES ($1, $2, $3, $4, $5)").await?; + let _ = conn.execute(&stmt, &[&binary_cache.name, &binary_cache.access_key, &binary_cache.secret_key, &binary_cache.region, &binary_cache.endpoint]).await?; Ok(()) } @@ -223,4 +232,17 @@ impl AppState<'_> { }) } + pub async fn get_project_summaries(&self) -> Result> { + let conn = self.db.get().await?; + let stmt = conn.prepare_cached("SELECT p.name, p FROM Projects p \ + INNER JOIN Closures c ON c.project_id = p.id").await?; + let rows = conn.query(&stmt, &[]).await?; + Ok( + rows.into_iter().map(|r| ProjectSummary { + name: r.get(0), + latest_closure: r.get(1), + latest_closure_datetime: r.get(2) + }).collect() + ) + } } diff --git a/src/server/bin/main.rs b/src/server/bin/main.rs index dba1362..28e3754 100644 --- a/src/server/bin/main.rs +++ b/src/server/bin/main.rs @@ -38,6 +38,8 @@ async fn main() -> std::io::Result<()> { .route("/login", web::get().to(handlers::webauthn_login)) .route("/login/init", web::post().to(handlers::webauthn_login_init)) .route("/login/finish", web::post().to(handlers::webauthn_login_finish)) + .route("/binary-cache/new", web::get().to(handlers::new_binary_cache)) + .route("/binary-cache/new", web::post().to(handlers::new_binary_cache_post)) }) .bind(addr) .unwrap() diff --git a/src/templates/landing.hbs b/src/templates/landing.hbs index 51afbcb..cdf255c 100644 --- a/src/templates/landing.hbs +++ b/src/templates/landing.hbs @@ -1,4 +1,23 @@ {{#> template }} -

Hello world, this is the nom nom S3 GC

-

Logged? {{ logged }}

+

Binary Caches

+New Binary Cache +{{#each binaryCaches}} +
+

{{this.name}}

+ + + + + + + {{#each this.projects}} + + + + + + {{/each}} +
Project NameLatest ClosureDatetime
{{this.name}}{{this.latestClosure}}{{this.datetime}}
+
+{{/each}} {{ /template }} diff --git a/src/templates/mod.rs b/src/templates/mod.rs index accae10..69a6c98 100644 --- a/src/templates/mod.rs +++ b/src/templates/mod.rs @@ -4,7 +4,7 @@ use handlebars::Handlebars; use std::{path::PathBuf, sync::Arc}; -use crate::models::RegistrationUuid; +use crate::models::{RegistrationUuid, ProjectSummary}; pub fn new<'a>() -> Result, RenderError> { let rootpath = PathBuf::from(env!("CARGO_MANIFEST_DIR")); @@ -16,6 +16,7 @@ pub fn new<'a>() -> Result, RenderError> { let webauthn_register_js = rootpath.join("src/templates/webauthn-register.js"); let webauthn_login_js = rootpath.join("src/templates/webauthn-login.js"); let login = rootpath.join("src/templates/login.hbs"); + let new_binary_cache_form = rootpath.join("src/templates/new-binary-cache.hbs"); hbs.register_template_file("landing", landing_path.to_str().unwrap())?; hbs.register_template_file("template", template_path.to_str().unwrap())?; @@ -24,17 +25,28 @@ pub fn new<'a>() -> Result, RenderError> { hbs.register_template_file("webauthn-login-js", webauthn_login_js.to_str().unwrap())?; hbs.register_template_file("register-user", register_user.to_str().unwrap())?; hbs.register_template_file("login", login.to_str().unwrap())?; + hbs.register_template_file("new-binary-cache-form", new_binary_cache_form.to_str().unwrap())?; Ok(hbs) } -pub fn landing_page(hb: Arc>, logged: bool) -> Result { +pub fn landing_page(hb: Arc>, logged: bool, project_summaries: Vec) -> Result { let data = json!({ - "logged": logged - }); + "binaryCaches": [{ + "name": "NixOS Binary Cache", + "projects": project_summaries.into_iter().map(|p| json!({ + "name": p.name, + "latestClosure": p.latest_closure, + "datetime": p.latest_closure_datetime.to_string() + } + )).collect::>() + }]}); hb.render("landing", &data) } +/** +Generates a webauthn challenge to initiate a fido key enrolling procedure. +*/ pub fn register_user_start(hb: Arc>, registration_uuid: RegistrationUuid, username: String, keyids: Vec) -> Result { let js_data = json!({ "registration-uuid": ®istration_uuid.0.to_string(), @@ -48,8 +60,7 @@ pub fn register_user_start(hb: Arc>, registration_uuid: Registrat hb.render("register-user", &data) } - -pub fn login(hb: Arc>, ) -> Result { +pub fn login(hb: Arc>) -> Result { let js_data = json!({ }); let js = hb.render("webauthn-login-js", &js_data)?; @@ -58,3 +69,9 @@ pub fn login(hb: Arc>, ) -> Result { }); hb.render("login", &data) } + +pub fn new_binary_cache(hb: Arc>) -> Result { + let data = json!({ + }); + hb.render("new-binary-cache-form", &data) +} diff --git a/src/templates/new-binary-cache.hbs b/src/templates/new-binary-cache.hbs new file mode 100644 index 0000000..a6bb34a --- /dev/null +++ b/src/templates/new-binary-cache.hbs @@ -0,0 +1,16 @@ +{{#> template }} +

New Binary Cache

+
+ + + + + + + + + + + +
+{{ /template }} \ No newline at end of file