From 11f3210fa0814e03eb259673934aa675744e6085 Mon Sep 17 00:00:00 2001 From: Szepesi Tibor Date: Mon, 1 Jul 2024 21:02:50 +0200 Subject: [PATCH] Upgrade deps --- Cargo.lock | 513 +++++++++++++++++++++++++++++--------- Cargo.toml | 16 +- src/error/mod.rs | 2 +- src/iam.rs | 12 +- src/json.rs | 19 +- src/lib.rs | 17 +- src/main.rs | 38 +-- src/middlewares/claims.rs | 10 +- tests/utils/mod.rs | 13 +- 9 files changed, 461 insertions(+), 179 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3accfbca..8bfef372 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -140,6 +140,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + [[package]] name = "arc-swap" version = "1.6.0" @@ -277,6 +283,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.1.0" @@ -290,15 +302,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core", - "base64 0.21.0", + "axum-core 0.3.4", "bitflags 1.3.2", "bytes", "futures-util", - "headers", - "http", - "http-body", - "hyper", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.24", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core 0.4.3", + "base64 0.21.7", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.4.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -311,12 +351,13 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.21.0", "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -328,12 +369,33 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -372,9 +434,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" @@ -1048,9 +1110,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1210,7 +1272,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.9", + "indexmap 2.1.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", "indexmap 2.1.0", "slab", "tokio", @@ -1244,15 +1325,14 @@ dependencies = [ [[package]] name = "headers" -version = "0.3.8" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" +checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.21.7", "bytes", "headers-core", - "http", + "http 1.1.0", "httpdate", "mime", "sha1", @@ -1260,11 +1340,11 @@ dependencies = [ [[package]] name = "headers-core" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" dependencies = [ - "http", + "http 1.1.0", ] [[package]] @@ -1338,6 +1418,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -1345,15 +1436,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.9", "pin-project-lite", ] [[package]] -name = "http-range-header" -version = "0.3.0" +name = "http-body" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "pin-project-lite", +] [[package]] name = "httparse" @@ -1377,9 +1485,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.22", + "http 0.2.9", + "http-body 0.4.5", "httparse", "httpdate", "itoa", @@ -1391,6 +1499,27 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -1398,20 +1527,58 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.9", + "hyper 0.14.24", "rustls 0.21.8", "tokio", "tokio-rustls 0.24.1", ] +[[package]] +name = "hyper-rustls" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.4.0", + "hyper-util", + "rustls 0.23.10", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", + "webpki-roots 0.26.3", +] + +[[package]] +name = "hyper-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.4.0", + "pin-project-lite", + "socket2 0.5.5", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iam-common" version = "0.1.0" source = "git+https://github.com/Verseghy/iam#666e71c898e450ea3fd17a52d793f37734d56e41" dependencies = [ - "axum", - "base64 0.21.0", + "axum 0.6.20", + "base64 0.21.7", "bcrypt", "bytes", "chrono", @@ -1480,30 +1647,14 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", ] -[[package]] -name = "if_chain" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" - [[package]] name = "indexmap" version = "1.9.2" @@ -1614,7 +1765,7 @@ version = "9.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "155c4d7e39ad04c172c5e3a99c434ea3b4a7ba7960b38ecd562b270b097cce09" dependencies = [ - "base64 0.21.0", + "base64 0.21.7", "pem 3.0.2", "ring 0.17.5", "serde", @@ -1647,7 +1798,7 @@ dependencies = [ "iam-common", "iam-entity", "jsonwebtoken 9.1.0", - "reqwest", + "reqwest 0.11.22", "sea-orm 0.10.7", "serde", "serde_json", @@ -1735,16 +1886,18 @@ checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" name = "matverseny-backend" version = "0.1.0" dependencies = [ + "anyhow", "assert-json-diff", "async-nats", - "axum", + "axum 0.7.5", "bytes", "chrono", "const_format", "dotenvy", "entity", "futures", - "http", + "headers", + "http 1.1.0", "jsonwebtoken 9.1.0", "libiam", "macros", @@ -1755,7 +1908,7 @@ dependencies = [ "pin-project-lite", "rand", "rand_chacha", - "reqwest", + "reqwest 0.12.5", "sea-orm 0.12.7", "serde", "serde_json", @@ -1764,7 +1917,7 @@ dependencies = [ "smallvec", "sqlx 0.7.2", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.23.1", "tower", "tower-http", "tracing", @@ -1969,9 +2122,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" dependencies = [ "parking_lot_core 0.9.7", ] @@ -2113,7 +2266,7 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3163d2912b7c3b52d651a055f2c7eec9ba5cd22d26ef75b8dd3a59980b185923" dependencies = [ - "base64 0.21.0", + "base64 0.21.7", "serde", ] @@ -2137,9 +2290,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" @@ -2273,6 +2426,53 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls 0.23.10", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +dependencies = [ + "bytes", + "rand", + "ring 0.17.5", + "rustc-hash", + "rustls 0.23.10", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +dependencies = [ + "libc", + "once_cell", + "socket2 0.5.5", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.33" @@ -2402,16 +2602,16 @@ version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.0", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-rustls", + "h2 0.3.22", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.24", + "hyper-rustls 0.24.2", "ipnet", "js-sys", "log", @@ -2433,7 +2633,49 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.25.2", - "winreg", + "winreg 0.50.0", +] + +[[package]] +name = "reqwest" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.4.0", + "hyper-rustls 0.27.2", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls 0.23.10", + "rustls-pemfile 2.1.2", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots 0.26.3", + "winreg 0.52.0", ] [[package]] @@ -2522,6 +2764,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.4.0" @@ -2601,7 +2849,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64 0.21.0", + "base64 0.21.7", ] [[package]] @@ -3031,7 +3279,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ - "base64 0.21.0", + "base64 0.21.7", "chrono", "hex", "indexmap 1.9.2", @@ -3170,9 +3418,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" @@ -3423,7 +3671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" dependencies = [ "atoi 2.0.0", - "base64 0.21.0", + "base64 0.21.7", "bitflags 2.4.1", "byteorder", "bytes", @@ -3467,7 +3715,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" dependencies = [ "atoi 2.0.0", - "base64 0.21.0", + "base64 0.21.7", "bitflags 2.4.1", "byteorder", "chrono", @@ -3598,6 +3846,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -3792,14 +4046,26 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", "tokio", - "tungstenite", + "tungstenite 0.21.0", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.23.0", ] [[package]] @@ -3834,18 +4100,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "async-compression", "bitflags 2.4.1", "bytes", "futures-core", "futures-util", - "http", - "http-body", - "http-range-header", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "pin-project-lite", "tokio", "tokio-util", @@ -3949,14 +4215,14 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 1.1.0", "httparse", "log", "rand", @@ -3966,6 +4232,24 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tungstenite" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "utf-8", +] + [[package]] name = "typenum" version = "1.16.0" @@ -4031,12 +4315,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.3.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", - "idna 0.3.0", + "idna", "percent-encoding", ] @@ -4066,12 +4350,12 @@ dependencies = [ [[package]] name = "validator" -version = "0.16.1" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b92f40481c04ff1f4f61f304d61793c7b56ff76ac1469f1beb199b1445b253bd" +checksum = "db79c75af171630a3148bd3e6d7c4f42b6a9a014c2945bc5ed0020cbb8d9478e" dependencies = [ - "idna 0.4.0", - "lazy_static", + "idna", + "once_cell", "regex", "serde", "serde_derive", @@ -4082,28 +4366,16 @@ dependencies = [ [[package]] name = "validator_derive" -version = "0.16.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc44ca3088bb3ba384d9aecf40c6a23a676ce23e09bdaca2073d99c207f864af" +checksum = "55591299b7007f551ed1eb79a684af7672c19c3193fb9e0a31936987bb2438ec" dependencies = [ - "if_chain", - "lazy_static", + "darling", + "once_cell", "proc-macro-error", "proc-macro2", "quote", - "regex", - "syn 1.0.109", - "validator_types", -] - -[[package]] -name = "validator_types" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111abfe30072511849c5910134e8baf8dc05de4c0e5903d681cbd5c9c4d611e3" -dependencies = [ - "proc-macro2", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] @@ -4250,6 +4522,15 @@ version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +[[package]] +name = "webpki-roots" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "whoami" version = "1.3.0" @@ -4502,6 +4783,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "zerocopy" version = "0.7.25" diff --git a/Cargo.toml b/Cargo.toml index a199b205..94afbfce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version.workspace = true edition.workspace = true publish.workspace = true license-file.workspace = true -rust-version = "1.74" +rust-version = "1.76" default-run = "matverseny-backend" [lints] @@ -61,17 +61,17 @@ members = [".", "entity", "migration", "macros", "cmds"] default-members = [".", "migration", "cmds"] [dependencies] -axum = { version = "0.6.20", features = ["ws", "http2", "headers"] } +axum = { version = "0.7.5", features = ["ws", "http2"] } serde = { version = "1.0.193", features = ["derive"] } tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread", "signal", "parking_lot", "sync"] } tower = "0.4.13" -tower-http = { version = "0.4.4", features = ["cors", "compression-full", "decompression-full", "catch-panic", "sensitive-headers", "request-id", "util", "normalize-path"] } +tower-http = { version = "0.5.2", features = ["cors", "compression-full", "decompression-full", "catch-panic", "sensitive-headers", "request-id", "util", "normalize-path"] } tracing = "0.1.40" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } entity = { path = "./entity" } sea-orm = { version = "0.12.7", default-features = false, features = ["runtime-tokio-rustls", "sqlx-postgres", "with-uuid", "with-chrono"] } serde_json = "1.0.108" -validator = { version = "0.16.1", features = ["derive"] } +validator = { version = "0.18.1", features = ["derive"] } pin-project = "1.1.3" jsonwebtoken = "9.1.0" once_cell = { version = "1.18.0", features = ["parking_lot"] } @@ -79,7 +79,7 @@ rand = "0.8.5" futures = "0.3.29" rand_chacha = "0.3.1" serde_with = "3.4.0" -tokio-tungstenite = "0.20.1" +tokio-tungstenite = "0.23.1" sqlx = { version = "0.7.2", default-features = false, features = ["postgres"] } uuid.workspace = true bytes = "1.5.0" @@ -88,17 +88,19 @@ macros = { path = "./macros/" } smallvec = "1.11.1" const_format = "0.2.32" pin-project-lite = "0.2.13" -reqwest = { version = "0.11.22", default-features = false, features = ["json", "rustls-tls"] } +reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls"] } libiam = { git = "https://github.com/Verseghy/iam", package = "libiam" } chrono = { version = "0.4.31", features = ["serde"] } async-nats = "0.35.1" +headers = "0.4.0" +anyhow = "1.0.86" [workspace.dependencies] uuid = { version = "1.5.0", features = ["v4", "fast-rng", "serde"] } [dev-dependencies] dotenvy = "0.15.7" -http = "0.2.9" +http = "1.1.0" migration = { path = "./migration" } assert-json-diff = "2.0.2" serial_test = "2.0.0" diff --git a/src/error/mod.rs b/src/error/mod.rs index 9b370d13..3c5af151 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -153,7 +153,7 @@ mod tests { fn error_response_has_json_content_type() { let error = Error::new(Some(StatusCode::OK), "", ""); let response = error.into_response(); - let content_type = response.headers().get(http::header::CONTENT_TYPE); + let content_type = response.headers().get(header::CONTENT_TYPE); assert!(content_type.is_some(), "response"); assert_eq!(content_type.unwrap(), "application/json"); diff --git a/src/iam.rs b/src/iam.rs index 7f0b15b8..a843a52b 100644 --- a/src/iam.rs +++ b/src/iam.rs @@ -9,20 +9,10 @@ use serde::Deserialize; use std::env; use uuid::Uuid; -#[derive(Debug, Deserialize)] +#[derive(Debug, Clone, Deserialize)] pub struct Claims { - #[serde(rename = "iss")] - pub issuer: String, #[serde(rename = "sub", deserialize_with = "deserialize_subject")] pub subject: Uuid, - #[serde(rename = "aud")] - pub audience: Vec, - #[serde(rename = "exp")] - pub expires_at: i64, - #[serde(rename = "nbf")] - pub not_before: i64, - #[serde(rename = "iat")] - pub issued_at: i64, } #[async_trait] diff --git a/src/json.rs b/src/json.rs index bd817e0c..c36f3ac0 100644 --- a/src/json.rs +++ b/src/json.rs @@ -1,11 +1,8 @@ use crate::{error, Error}; use axum::{ async_trait, - body::HttpBody, - extract::{rejection::JsonRejection, FromRequest}, - http::Request, + extract::{rejection::JsonRejection, FromRequest, Request}, response::{IntoResponse, Response}, - BoxError, }; use serde::{de::DeserializeOwned, Serialize}; use validator::Validate; @@ -13,17 +10,14 @@ use validator::Validate; pub struct Json(pub T); #[async_trait] -impl FromRequest for Json +impl FromRequest for Json where T: DeserializeOwned, - B: HttpBody + Send + 'static, - B::Data: Send, - B::Error: Into, S: Send + Sync, { type Rejection = Error<'static>; - async fn from_request(req: Request, state: &S) -> Result { + async fn from_request(req: Request, state: &S) -> Result { match axum::Json::::from_request(req, state).await { Ok(value) => Ok(Self(value.0)), Err(rejection) => match rejection { @@ -49,17 +43,14 @@ where pub struct ValidatedJson(pub T); #[async_trait] -impl FromRequest for ValidatedJson +impl FromRequest for ValidatedJson where T: DeserializeOwned + Validate, - B: HttpBody + Send + 'static, - B::Data: Send, - B::Error: Into, S: Send + Sync, { type Rejection = Error<'static>; - async fn from_request(req: Request, state: &S) -> Result { + async fn from_request(req: Request, state: &S) -> Result { let Json(json) = Json::::from_request(req, state).await?; json.validate().map_err(|_| error::JSON_VALIDATE_INVALID)?; diff --git a/src/lib.rs b/src/lib.rs index 88635309..e2d5e8f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,15 +10,15 @@ mod state; mod utils; use crate::{middlewares::middlewares, utils::SignalHandler}; -use axum::ServiceExt; +use axum::{extract::Request, ServiceExt}; use error::{Error, Result}; use json::*; pub use state::*; -use std::net::TcpListener; +use tokio::net::TcpListener; use tower_http::normalize_path::NormalizePath; pub use utils::panic; -pub async fn run(listener: TcpListener, state: S) { +pub async fn run(listener: TcpListener, state: S) -> anyhow::Result<()> { info!( "listening on port {}", listener.local_addr().unwrap().port() @@ -28,10 +28,9 @@ pub async fn run(listener: TcpListener, state: S) { let app = middlewares(state, app); let app = NormalizePath::trim_trailing_slash(app); - axum::Server::from_tcp(listener) - .expect("failed to start server") - .serve(app.into_make_service()) - .with_graceful_shutdown(SignalHandler::new()) - .await - .unwrap() + Ok( + axum::serve(listener, ServiceExt::::into_make_service(app)) + .with_graceful_shutdown(SignalHandler::new()) + .await?, + ) } diff --git a/src/main.rs b/src/main.rs index 0e8e0095..a896d720 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,29 +2,27 @@ use libiam::{App, Iam}; use matverseny_backend::State; use std::{ env, - net::{Ipv4Addr, SocketAddr, TcpListener}, + net::{Ipv4Addr, SocketAddr}, + process::ExitCode, }; -use tracing::level_filters::LevelFilter; +use tokio::net::TcpListener; +use tracing::{error, level_filters::LevelFilter}; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer}; -pub async fn login() -> App { - let Ok(iam_url) = env::var("IAM_URL") else { - panic!("IAM_URL is not set"); - }; +pub async fn login() -> anyhow::Result { + let iam_url = env::var("IAM_URL").inspect_err(|_| error!("IAM_URL is not set"))?; + let app_secret = + env::var("IAM_APP_SECRET").inspect_err(|_| error!("IAM_APP_SECRET is not set"))?; let iam = Iam::new(&iam_url); - let Ok(app_secret) = env::var("IAM_APP_SECRET") else { - panic!("IAM_APP_SECRET is not set"); - }; - - App::login(&iam, &app_secret) + Ok(App::login(&iam, &app_secret) .await - .expect("failed to login into the iam") + .inspect_err(|_| error!("failed to login into the iam"))?) } #[tokio::main] -async fn main() { +async fn main() -> ExitCode { let env_filter = EnvFilter::builder() .with_default_directive(LevelFilter::INFO.into()) .from_env_lossy(); @@ -35,12 +33,20 @@ async fn main() { matverseny_backend::panic::set_hook(); - let iam_app = login().await; + if run().await.is_err() { + ExitCode::FAILURE + } else { + ExitCode::SUCCESS + } +} + +async fn run() -> anyhow::Result<()> { + let iam_app = login().await?; let addr = SocketAddr::from((Ipv4Addr::UNSPECIFIED, 3002)); - let listener = TcpListener::bind(addr).expect("failed to bind tcp listener"); + let listener = TcpListener::bind(addr).await?; let state = State::new(iam_app).await; - matverseny_backend::run(listener, state).await; + matverseny_backend::run(listener, state).await } diff --git a/src/middlewares/claims.rs b/src/middlewares/claims.rs index 8b526fe0..41d1fdfc 100644 --- a/src/middlewares/claims.rs +++ b/src/middlewares/claims.rs @@ -1,10 +1,8 @@ use crate::{iam::IamTrait, StateTrait}; -use axum::{ - headers::{ - authorization::{Authorization, Bearer}, - HeaderMapExt, - }, - http::Request, +use axum::http::Request; +use headers::{ + authorization::{Authorization, Bearer}, + HeaderMapExt, }; use std::{ future::Future, diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs index beac10e8..b9f87c8b 100644 --- a/tests/utils/mod.rs +++ b/tests/utils/mod.rs @@ -16,14 +16,17 @@ use request::*; use reqwest::Client; use serde_json::{json, Value}; use std::{ - net::{Ipv4Addr, SocketAddr, TcpListener}, + net::{Ipv4Addr, SocketAddr}, sync::{ atomic::{AtomicU64, Ordering}, Arc, }, }; use team::Team; -use tokio::sync::{oneshot, OnceCell}; +use tokio::{ + net::TcpListener, + sync::{oneshot, OnceCell}, +}; use tokio_tungstenite::tungstenite::Message; use user::*; use uuid::Uuid; @@ -76,7 +79,9 @@ impl App { tracing::trace!("binding socket"); let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 0)); - let listener = TcpListener::bind(addr).expect("failed to bind tcp listener"); + let listener = TcpListener::bind(addr) + .await + .expect("failed to bind tcp listener"); let state = State::with_database(iam_app, conn.conn()).await; let inner = Arc::new(AppInner { @@ -88,7 +93,7 @@ impl App { tracing::trace!("starting app"); - matverseny_backend::run(listener, state).await; + matverseny_backend::run(listener, state).await.unwrap(); }); });