From 21fc2587d424ff5296354d0e6eaea57e4454dbfb Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 31 Oct 2023 22:03:48 +0100 Subject: [PATCH 01/11] feat: axum type 0.7 Signed-off-by: kjuulh --- Cargo.lock | 520 +++++++++++++++++++---------- Cargo.toml | 4 +- crates/nefarious-login/Cargo.toml | 2 +- crates/nefarious-login/src/axum.rs | 9 +- examples/basic/src/main.rs | 13 +- examples/clap/src/main.rs | 11 +- 6 files changed, 364 insertions(+), 195 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ce6ba7..4e29e31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom", "once_cell", @@ -65,14 +65,15 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if 1.0.0", "getrandom", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -204,7 +205,7 @@ checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" dependencies = [ "async-channel", "async-executor", - "async-io", + "async-io 1.13.0", "async-lock", "blocking", "futures-lite", @@ -224,13 +225,33 @@ dependencies = [ "futures-lite", "log", "parking", - "polling", - "rustix 0.37.26", + "polling 2.8.0", + "rustix 0.37.27", "slab", "socket2 0.4.10", "waker-fn", ] +[[package]] +name = "async-io" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10da8f3146014722c89e7859e1d7bb97873125d7346d10ca642ffab794355828" +dependencies = [ + "async-lock", + "cfg-if 1.0.0", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling 3.3.0", + "rustix 0.38.21", + "slab", + "tracing", + "waker-fn", + "windows-sys", +] + [[package]] name = "async-lock" version = "2.8.0" @@ -258,14 +279,14 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" dependencies = [ - "async-io", + "async-io 1.13.0", "async-lock", "async-signal", "blocking", "cfg-if 1.0.0", - "event-listener 3.0.0", + "event-listener 3.0.1", "futures-lite", - "rustix 0.38.20", + "rustix 0.38.21", "windows-sys", ] @@ -292,17 +313,17 @@ dependencies = [ [[package]] name = "async-signal" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a5415b7abcdc9cd7d63d6badba5288b2ca017e3fbd4173b8f405449f1a2399" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io", + "async-io 2.1.0", "async-lock", "atomic-waker", "cfg-if 1.0.0", "futures-core", "futures-io", - "rustix 0.38.20", + "rustix 0.38.21", "signal-hook-registry", "slab", "windows-sys", @@ -326,7 +347,7 @@ checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ "async-channel", "async-global-executor", - "async-io", + "async-io 1.13.0", "async-lock", "async-process", "crossbeam-utils", @@ -392,6 +413,40 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.6.16" +source = "git+https://github.com/tokio-rs/axum?branch=main#d7258bf009194cf2f242694e673759d1dbf8cfc0" +dependencies = [ + "async-trait", + "axum-core 0.3.4 (git+https://github.com/tokio-rs/axum?branch=main)", + "axum-macros 0.3.7", + "bytes", + "futures-util", + "http", + "http-body 0.4.5", + "hyper 0.14.27", + "hyper 1.0.0-rc.4", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-hyper-http-body-compat", + "tower-layer", + "tower-service", +] + [[package]] name = "axum" version = "0.6.20" @@ -399,15 +454,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core", - "axum-macros", + "axum-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "axum-macros 0.3.8", "bitflags 1.3.2", "bytes", "futures-util", "headers", "http", - "http-body", - "hyper", + "http-body 0.4.5", + "hyper 0.14.27", "itoa", "matchit", "memchr", @@ -436,26 +491,65 @@ dependencies = [ "bytes", "futures-util", "http", - "http-body", + "http-body 0.4.5", "mime", "rustversion", "tower-layer", "tower-service", ] +[[package]] +name = "axum-core" +version = "0.3.4" +source = "git+https://github.com/tokio-rs/axum?branch=main#d7258bf009194cf2f242694e673759d1dbf8cfc0" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body 0.4.5", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-extra" +version = "0.7.4" +source = "git+https://github.com/tokio-rs/axum?branch=main#d7258bf009194cf2f242694e673759d1dbf8cfc0" +dependencies = [ + "axum 0.6.16", + "axum-core 0.3.4 (git+https://github.com/tokio-rs/axum?branch=main)", + "bytes", + "cookie", + "futures-util", + "headers", + "http", + "http-body 0.4.5", + "mime", + "pin-project-lite", + "serde", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "axum-extra" version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a93e433be9382c737320af3924f7d5fc6f89c155cf2bf88949d8f5126fab283f" dependencies = [ - "axum", - "axum-core", + "axum 0.6.20", + "axum-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes", "cookie", "futures-util", "http", - "http-body", + "http-body 0.4.5", "mime", "pin-project-lite", "serde", @@ -471,13 +565,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ab90e7b70bea63a153137162affb6a0bce26b584c24a4c7885509783e2cf30b" dependencies = [ - "axum", - "axum-core", + "axum 0.6.20", + "axum-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes", - "cookie", "futures-util", "http", - "http-body", + "http-body 0.4.5", "mime", "pin-project-lite", "serde", @@ -487,6 +580,17 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-macros" +version = "0.3.7" +source = "git+https://github.com/tokio-rs/axum?branch=main#d7258bf009194cf2f242694e673759d1dbf8cfc0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "axum-macros" version = "0.3.8" @@ -506,10 +610,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c84930174d586fdc66a8c317cdf48b8bb487a1d079c38efc67d81a80c11c664f" dependencies = [ "async-session", - "axum", + "axum 0.6.20", "axum-extra 0.7.7", "futures", - "http-body", + "http-body 0.4.5", "tokio", "tower", "tracing", @@ -544,9 +648,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64-compat" @@ -568,7 +672,7 @@ name = "basic" version = "0.1.0" dependencies = [ "anyhow", - "axum", + "axum 0.6.16", "clap 4.4.7", "nefarious-login", "tokio", @@ -717,7 +821,7 @@ name = "clap" version = "0.1.0" dependencies = [ "anyhow", - "axum", + "axum 0.6.16", "clap 4.4.7", "nefarious-login", "tokio", @@ -798,7 +902,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" dependencies = [ "aes-gcm", - "base64 0.21.4", + "base64 0.21.5", "hmac 0.12.1", "percent-encoding", "rand", @@ -826,9 +930,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -848,7 +952,7 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" dependencies = [ - "crc-catalog 2.2.0", + "crc-catalog 2.3.0", ] [[package]] @@ -859,9 +963,9 @@ checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "4939f9ed1444bd8c896d37f3090012fa6e7834fe84ef8c9daa166109515732f9" [[package]] name = "crossbeam-queue" @@ -953,9 +1057,9 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", @@ -1200,9 +1304,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e56284f00d94c1bc7fd3c77027b4623c88c1f53d8d2394c6199f2921dea325" +checksum = "01cec0252c2afff729ee6f00e903d479fba81784c8e2bd77447673471fdfaea1" dependencies = [ "concurrent-queue", "parking", @@ -1236,9 +1340,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "a481586acf778f1b1455424c343f71124b048ffa5f4fc3f8f6ae9dc432dcb3c7" [[package]] name = "finl_unicode" @@ -1295,9 +1399,9 @@ checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -1310,9 +1414,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -1320,15 +1424,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -1359,9 +1463,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" @@ -1380,9 +1484,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", @@ -1391,21 +1495,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -1507,7 +1611,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] @@ -1522,7 +1626,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "allocator-api2", ] @@ -1550,7 +1654,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "headers-core", "http", @@ -1648,6 +1752,16 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-body" +version = "1.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951dfc2e32ac02d67c90c0d65bd27009a635dc9b381a2cc7d284ab01e3a0150d" +dependencies = [ + "bytes", + "http", +] + [[package]] name = "http-range-header" version = "0.3.1" @@ -1678,7 +1792,7 @@ dependencies = [ "futures-util", "h2", "http", - "http-body", + "http-body 0.4.5", "httparse", "httpdate", "itoa", @@ -1691,19 +1805,60 @@ dependencies = [ ] [[package]] -name = "hyper-rustls" -version = "0.24.1" +name = "hyper" +version = "1.0.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "d280a71f348bcc670fc55b02b63c53a04ac0bf2daff2980795aeaf53edae10e6" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body 1.0.0-rc.2", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", + "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", + "hyper 0.14.27", "rustls", "tokio", "tokio-rustls", ] +[[package]] +name = "hyper-util" +version = "0.0.0" +source = "git+https://github.com/hyperium/hyper-util?rev=d97181a#d97181a278d9c59f1d7f2713732e400440861216" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body 1.0.0-rc.2", + "hyper 1.0.0-rc.4", + "once_cell", + "pin-project-lite", + "socket2 0.5.5", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.58" @@ -1756,9 +1911,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.2", @@ -1826,9 +1981,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -1839,9 +1994,9 @@ version = "9.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "155c4d7e39ad04c172c5e3a99c434ea3b4a7ba7960b38ecd562b270b097cce09" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "pem", - "ring 0.17.5", + "ring", "serde", "serde_json", "simple_asn1", @@ -1973,9 +2128,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi", @@ -2007,8 +2162,8 @@ dependencies = [ "anyhow", "async-sqlx-session", "async-trait", - "axum", - "axum-extra 0.8.0", + "axum 0.6.16", + "axum-extra 0.7.4", "axum-sessions", "clap 4.4.7", "oauth2", @@ -2337,7 +2492,7 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3163d2912b7c3b52d651a055f2c7eec9ba5cd22d26ef75b8dd3a59980b185923" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "serde", ] @@ -2428,9 +2583,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" -version = "3.1.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" [[package]] name = "polling" @@ -2448,6 +2603,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "polling" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" +dependencies = [ + "cfg-if 1.0.0", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.21", + "tracing", + "windows-sys", +] + [[package]] name = "polyval" version = "0.6.1" @@ -2554,15 +2723,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -2633,15 +2793,15 @@ version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "encoding_rs", "futures-core", "futures-util", "h2", "http", - "http-body", - "hyper", + "http-body 0.4.5", + "hyper 0.14.27", "hyper-rustls", "ipnet", "js-sys", @@ -2677,21 +2837,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.5" @@ -2702,22 +2847,20 @@ dependencies = [ "getrandom", "libc", "spin 0.9.8", - "untrusted 0.9.0", + "untrusted", "windows-sys", ] [[package]] name = "rsa" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8" +checksum = "86ef35bf3e7fe15a53c4ab08a998e42271eab13eb0db224126bc7bc4c4bad96d" dependencies = [ - "byteorder", "const-oid", "digest 0.10.7", "num-bigint-dig", "num-integer", - "num-iter", "num-traits", "pkcs1", "pkcs8", @@ -2745,9 +2888,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.26" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f3f8f960ed3b5a59055428714943298bf3fa2d4a1d53135084e0544829d995" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", @@ -2759,9 +2902,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.20" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ "bitflags 2.4.1", "errno", @@ -2772,12 +2915,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring 0.16.20", + "ring", "rustls-webpki", "sct", ] @@ -2788,17 +2931,17 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", ] [[package]] name = "rustls-webpki" -version = "0.101.6" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring", + "untrusted", ] [[package]] @@ -2842,12 +2985,12 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring", + "untrusted", ] [[package]] @@ -2917,9 +3060,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] @@ -2936,9 +3079,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", @@ -2993,11 +3136,11 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.0.2", + "indexmap 2.1.0", "serde", "serde_json", "serde_with_macros", @@ -3213,7 +3356,7 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c61941ccf5ddcada342cd59e3e5173b007c509e1e8e990dafc830294d9dc5" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", "atoi 0.4.0", "base64 0.13.1", "bitflags 1.3.2", @@ -3262,7 +3405,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d6753e460c998bbd4cd8c6f0ed9a64346fcca0723d6e75e52fdc351c5d2169d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "atoi 2.0.0", "byteorder", "bytes", @@ -3278,7 +3421,7 @@ dependencies = [ "futures-util", "hashlink 0.8.4", "hex", - "indexmap 2.0.2", + "indexmap 2.1.0", "log", "memchr", "once_cell", @@ -3365,7 +3508,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" dependencies = [ "atoi 2.0.0", - "base64 0.21.4", + "base64 0.21.5", "bitflags 2.4.1", "byteorder", "bytes", @@ -3407,7 +3550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" dependencies = [ "atoi 2.0.0", - "base64 0.21.4", + "base64 0.21.5", "bitflags 2.4.1", "byteorder", "crc 3.0.1", @@ -3546,14 +3689,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if 1.0.0", "fastrand 2.0.1", - "redox_syscall 0.3.5", - "rustix 0.38.20", + "redox_syscall 0.4.1", + "rustix 0.38.21", "windows-sys", ] @@ -3684,9 +3827,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -3723,7 +3866,7 @@ dependencies = [ "futures-core", "futures-util", "http", - "http-body", + "http-body 0.4.5", "http-range-header", "pin-project-lite", "tower-layer", @@ -3731,6 +3874,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower-hyper-http-body-compat" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ea3e622710ee44a8255baa6fcb2a34d67450e2ffb48e5e58d5a7bd6ff55a21" +dependencies = [ + "http", + "http-body 0.4.5", + "http-body 1.0.0-rc.2", + "hyper 1.0.0-rc.4", + "pin-project-lite", + "tower", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.2" @@ -3778,12 +3936,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -3860,12 +4018,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -3952,9 +4104,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -3962,9 +4114,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", @@ -3977,9 +4129,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3989,9 +4141,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3999,9 +4151,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", @@ -4012,15 +4164,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -4164,6 +4316,26 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "zerocopy" +version = "0.7.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686b7e407015242119c33dab17b8f61ba6843534de936d94368856528eae4dcc" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020f3dfe25dfc38dfea49ce62d5d45ecdd7f0d8a724fa63eb36b6eba4ec76806" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "zeroize" version = "1.6.0" @@ -4176,7 +4348,7 @@ version = "3.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aab76990d831d980e72e52f6eed5ef8e4a740ee7ad14c65e1a3374b974f92258" dependencies = [ - "axum", + "axum 0.6.20", "axum-extra 0.8.0", "base64-compat", "custom_error", diff --git a/Cargo.toml b/Cargo.toml index 102dd69..a789bb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } clap = {version = "4.4.7", features = ["derive", "env"]} async-trait = {version = "0.1.74", features = []} -axum = {version = "0.6.20", features = []} -axum-extra = {version = "0.8.0", features = ["cookie", "cookie-private"]} +axum = { git = "https://github.com/tokio-rs/axum", branch = "main", features = ["macros"] } +axum-extra = {git = "https://github.com/tokio-rs/axum", branch = "main" , features = ["cookie", "cookie-private", "typed-header"]} axum-sessions = {version = "0.6.1", features = []} async-sqlx-session = {version = "0.4.0", features = ["pg"]} diff --git a/crates/nefarious-login/Cargo.toml b/crates/nefarious-login/Cargo.toml index a0e09ab..1d83e6d 100644 --- a/crates/nefarious-login/Cargo.toml +++ b/crates/nefarious-login/Cargo.toml @@ -26,4 +26,4 @@ openidconnect.workspace = true [dev-dependencies] tokio.workspace = true pretty_assertions.workspace = true -sealed_test.workspace = true \ No newline at end of file +sealed_test.workspace = true diff --git a/crates/nefarious-login/src/axum.rs b/crates/nefarious-login/src/axum.rs index d624b52..81d4762 100644 --- a/crates/nefarious-login/src/axum.rs +++ b/crates/nefarious-login/src/axum.rs @@ -1,16 +1,15 @@ use std::fmt::Display; use axum::extract::{FromRef, FromRequestParts, Query, State}; - -use axum::headers::authorization::Basic; -use axum::headers::{Authorization, Cookie}; use axum::http::request::Parts; use axum::http::StatusCode; - use axum::response::{ErrorResponse, IntoResponse, Redirect}; use axum::routing::get; -use axum::{async_trait, Json, RequestPartsExt, Router, TypedHeader}; +use axum::{async_trait, Json, RequestPartsExt, Router}; +use axum_extra::headers::authorization::Basic; +use axum_extra::headers::{Authorization, Cookie}; +use axum_extra::TypedHeader; use serde::Deserialize; use serde_json::json; diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index 1b0ea5b..084bfd1 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -1,4 +1,4 @@ -use std::net::SocketAddr; +use std::{net::SocketAddr, str::FromStr}; use axum::{ extract::{FromRef, State}, @@ -60,13 +60,10 @@ async fn main() -> anyhow::Result<()> { .with_state(state) .nest("/auth", AuthController::new_router(auth_service).await?); - let addr = SocketAddr::from(([127, 0, 0, 1], 3001)); - println!("listening on: {addr}"); - println!("open browser at: http://localhost:3001/auth/zitadel"); - axum::Server::bind(&addr) - .serve(app.into_make_service()) - .await - .unwrap(); + let addr = SocketAddr::from_str(&format!("{}:{}", "127.0.0.1", "3000"))?; + let listener = tokio::net::TcpListener::bind(&addr).await?; + + axum::serve(listener, app).await?; Ok(()) } diff --git a/examples/clap/src/main.rs b/examples/clap/src/main.rs index 428197e..84501ca 100644 --- a/examples/clap/src/main.rs +++ b/examples/clap/src/main.rs @@ -1,4 +1,4 @@ -use std::net::SocketAddr; +use std::{net::SocketAddr, str::FromStr}; use axum::{ extract::{FromRef, State}, @@ -58,10 +58,11 @@ async fn main() -> anyhow::Result<()> { let addr = SocketAddr::from(([127, 0, 0, 1], 3001)); println!("listening on: {addr}"); println!("open browser at: http://localhost:3001/auth/zitadel"); - axum::Server::bind(&addr) - .serve(app.into_make_service()) - .await - .unwrap(); + + let addr = SocketAddr::from_str(&format!("{}:{}", "127.0.0.1", "3000"))?; + let listener = tokio::net::TcpListener::bind(&addr).await?; + + axum::serve(listener, app).await?; Ok(()) } From 74362f3b1c7d1934b4984c87079c0958288de07f Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 31 Oct 2023 22:40:11 +0100 Subject: [PATCH 02/11] feat: with migrate Signed-off-by: kjuulh --- crates/nefarious-login/src/session.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/nefarious-login/src/session.rs b/crates/nefarious-login/src/session.rs index c933b3b..7cd5ce4 100644 --- a/crates/nefarious-login/src/session.rs +++ b/crates/nefarious-login/src/session.rs @@ -48,6 +48,8 @@ impl SessionService { ) .await?; + postgres_session.migrate().await?; + Ok(Self(Arc::new(PostgresSessionService { store: postgres_session, }))) From 70915aec652d072554b3f7e49034007d36d34fb1 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 4 Nov 2023 17:32:51 +0100 Subject: [PATCH 03/11] feat: change to more complete token instead of just id Signed-off-by: kjuulh --- crates/nefarious-login/src/auth.rs | 14 +++++------ crates/nefarious-login/src/axum.rs | 10 +++++--- crates/nefarious-login/src/introspection.rs | 27 ++++++++++++++++++--- crates/nefarious-login/src/session.rs | 22 ++++++++++------- 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/crates/nefarious-login/src/auth.rs b/crates/nefarious-login/src/auth.rs index 024980b..fbf7793 100644 --- a/crates/nefarious-login/src/auth.rs +++ b/crates/nefarious-login/src/auth.rs @@ -6,7 +6,7 @@ use axum::http::{header::SET_COOKIE, HeaderMap}; use oauth2::url::Url; use crate::{ - introspection::IntrospectionService, + introspection::{IdToken, IntrospectionService}, login::{auth_clap::AuthEngine, config::ConfigClap, AuthClap}, oauth::{zitadel::ZitadelConfig, OAuth}, session::{SessionService, User}, @@ -15,7 +15,7 @@ use crate::{ #[async_trait] pub trait Auth { async fn login(&self) -> anyhow::Result; - async fn login_token(&self, user: &str, password: &str) -> anyhow::Result; + async fn login_token(&self, user: &str, password: &str) -> anyhow::Result; async fn login_authorized(&self, code: &str, state: &str) -> anyhow::Result<(HeaderMap, Url)>; async fn get_user_from_session(&self, cookie: &str) -> anyhow::Result; } @@ -86,8 +86,8 @@ impl Auth for ZitadelAuthService { } async fn login_authorized(&self, code: &str, _state: &str) -> anyhow::Result<(HeaderMap, Url)> { let token = self.oauth.exchange(code).await?; - let user_id = self.introspection.get_id_token(token.as_str()).await?; - let cookie_value = self.session.insert_user("user", user_id.as_str()).await?; + let id_token = self.introspection.get_id_token(token.as_str()).await?; + let cookie_value = self.session.insert_user("user", id_token).await?; let cookie = format!("{}={}; SameSite=Lax; Path=/", COOKIE_NAME, cookie_value); @@ -100,12 +100,12 @@ impl Auth for ZitadelAuthService { .context("failed to parse login_authorized zitadel return url")?, )) } - async fn login_token(&self, _user: &str, password: &str) -> anyhow::Result { + async fn login_token(&self, _user: &str, password: &str) -> anyhow::Result { self.introspection.get_id_token(password).await } async fn get_user_from_session(&self, cookie: &str) -> anyhow::Result { match self.session.get_user(cookie).await? { - Some(u) => Ok(User { id: u }), + Some(u) => Ok(u), None => Err(anyhow::anyhow!("failed to find user")), } } @@ -126,7 +126,7 @@ impl Auth for NoopAuthService { todo!() } - async fn login_token(&self, _user: &str, _password: &str) -> anyhow::Result { + async fn login_token(&self, _user: &str, _password: &str) -> anyhow::Result { todo!() } diff --git a/crates/nefarious-login/src/axum.rs b/crates/nefarious-login/src/axum.rs index 81d4762..73d0663 100644 --- a/crates/nefarious-login/src/axum.rs +++ b/crates/nefarious-login/src/axum.rs @@ -121,7 +121,11 @@ where })?; return Ok(UserFromSession { - user: User { id: token }, + user: User { + id: token.sub, + email: token.email, + name: token.name, + }, }); } @@ -144,8 +148,6 @@ where ) })?; - Ok(UserFromSession { - user: User { id: user.id }, - }) + Ok(UserFromSession { user }) } } diff --git a/crates/nefarious-login/src/introspection.rs b/crates/nefarious-login/src/introspection.rs index 04fab13..3c1a001 100644 --- a/crates/nefarious-login/src/introspection.rs +++ b/crates/nefarious-login/src/introspection.rs @@ -4,6 +4,7 @@ use async_trait::async_trait; use axum::extract::FromRef; use oauth2::TokenIntrospectionResponse; use openidconnect::IntrospectionUrl; +use serde::{Deserialize, Serialize}; use zitadel::{ axum::introspection::IntrospectionStateBuilderError, credentials::Application, @@ -15,10 +16,17 @@ use zitadel::{ use crate::login::AuthClap; +#[derive(Clone, Serialize, Deserialize)] +pub struct IdToken { + pub sub: String, + pub email: String, + pub name: String, +} + #[async_trait] pub trait Introspection { async fn get_user(&self) -> anyhow::Result<()>; - async fn get_id_token(&self, token: &str) -> anyhow::Result; + async fn get_id_token(&self, token: &str) -> anyhow::Result; } pub struct IntrospectionService(Arc); @@ -61,7 +69,7 @@ impl Introspection for ZitadelIntrospection { async fn get_user(&self) -> anyhow::Result<()> { Ok(()) } - async fn get_id_token(&self, token: &str) -> anyhow::Result { + async fn get_id_token(&self, token: &str) -> anyhow::Result { let config = &self.state.config; let res = introspect( &config.introspection_uri, @@ -71,10 +79,21 @@ impl Introspection for ZitadelIntrospection { ) .await?; - Ok(res + let sub = res .sub() .ok_or(anyhow::anyhow!("could not find a userid (sub) in token"))? - .to_string()) + .to_string(); + + let extra = res.extra_fields(); + let email = extra.email.clone().ok_or(anyhow::anyhow!( + "could not find a email (scope email) in token" + ))?; + + let name = extra.name.clone().ok_or(anyhow::anyhow!( + "could not find a name (scope profile) in token" + ))?; + + Ok(IdToken { sub, email, name }) } } diff --git a/crates/nefarious-login/src/session.rs b/crates/nefarious-login/src/session.rs index 7cd5ce4..1667bc1 100644 --- a/crates/nefarious-login/src/session.rs +++ b/crates/nefarious-login/src/session.rs @@ -11,7 +11,7 @@ use async_trait::async_trait; use axum_sessions::async_session::{Session as AxumSession, SessionStore as AxumSessionStore}; use serde::{Deserialize, Serialize}; -use crate::login::AuthClap; +use crate::{introspection::IdToken, login::AuthClap}; #[derive(clap::Args, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct SessionClap { @@ -27,8 +27,8 @@ pub struct PostgresqlSessionClap { #[async_trait] pub trait Session { - async fn insert_user(&self, id: &str, user_id: &str) -> anyhow::Result; - async fn get_user(&self, cookie: &str) -> anyhow::Result>; + async fn insert_user(&self, id: &str, id_token: IdToken) -> anyhow::Result; + async fn get_user(&self, cookie: &str) -> anyhow::Result>; } pub struct SessionService(Arc); @@ -73,16 +73,20 @@ pub struct PostgresSessionService { #[derive(Serialize, Deserialize, Clone, Debug)] pub struct User { pub id: String, + pub email: String, + pub name: String, } #[async_trait] impl Session for PostgresSessionService { - async fn insert_user(&self, _id: &str, user_id: &str) -> anyhow::Result { + async fn insert_user(&self, _id: &str, id_token: IdToken) -> anyhow::Result { let mut session = AxumSession::new(); session.insert( "user", User { - id: user_id.to_string(), + id: id_token.sub, + email: id_token.email, + name: id_token.name, }, )?; @@ -94,14 +98,14 @@ impl Session for PostgresSessionService { Ok(cookie) } - async fn get_user(&self, cookie: &str) -> anyhow::Result> { + async fn get_user(&self, cookie: &str) -> anyhow::Result> { if let Some(session) = self.store.load_session(cookie.to_string()).await.unwrap() { if let Some(user) = session.get::("user") { tracing::debug!( "UserFromSession: session decoded success, user_id={:?}", user.id ); - Ok(Some(user.id)) + Ok(Some(user)) } else { Ok(None) } @@ -119,11 +123,11 @@ pub struct InMemorySessionService {} #[async_trait] impl Session for InMemorySessionService { - async fn insert_user(&self, _id: &str, _user_id: &str) -> anyhow::Result { + async fn insert_user(&self, _id: &str, _id_token: IdToken) -> anyhow::Result { todo!() } - async fn get_user(&self, _cookie: &str) -> anyhow::Result> { + async fn get_user(&self, _cookie: &str) -> anyhow::Result> { todo!() } } From d746ef0dd76a24d6353344e9279cc3cbc8582c81 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 4 Nov 2023 17:37:53 +0100 Subject: [PATCH 04/11] feat: with more scopes Signed-off-by: kjuulh --- crates/nefarious-login/src/oauth/zitadel.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/nefarious-login/src/oauth/zitadel.rs b/crates/nefarious-login/src/oauth/zitadel.rs index 0226eee..d889494 100644 --- a/crates/nefarious-login/src/oauth/zitadel.rs +++ b/crates/nefarious-login/src/oauth/zitadel.rs @@ -110,6 +110,8 @@ impl OAuthClient for ZitadelOAuthClient { .authorize_url(CsrfToken::new_random) .add_scope(Scope::new("identify".to_string())) .add_scope(Scope::new("openid".to_string())) + .add_scope(Scope::new("email".to_string())) + .add_scope(Scope::new("profile".to_string())) .url(); Ok(auth_url) From 9102ec4c1e1aa6dac379ae3f9522a94911f92ca6 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Fri, 10 Nov 2023 20:05:07 +0100 Subject: [PATCH 05/11] feat: update deps Signed-off-by: kjuulh --- Cargo.lock | 214 ++++++++++++++++++++++++++++++++--------------------- Cargo.toml | 36 +++++---- 2 files changed, 149 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e29e31..d816021 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -189,11 +189,11 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" dependencies = [ - "async-lock", + "async-lock 2.8.0", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite", + "futures-lite 1.13.0", "slab", ] @@ -206,9 +206,9 @@ dependencies = [ "async-channel", "async-executor", "async-io 1.13.0", - "async-lock", + "async-lock 2.8.0", "blocking", - "futures-lite", + "futures-lite 1.13.0", "once_cell", ] @@ -218,11 +218,11 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "cfg-if 1.0.0", "concurrent-queue", - "futures-lite", + "futures-lite 1.13.0", "log", "parking", "polling 2.8.0", @@ -234,15 +234,15 @@ dependencies = [ [[package]] name = "async-io" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10da8f3146014722c89e7859e1d7bb97873125d7346d10ca642ffab794355828" +checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ - "async-lock", + "async-lock 3.0.0", "cfg-if 1.0.0", "concurrent-queue", "futures-io", - "futures-lite", + "futures-lite 2.0.1", "parking", "polling 3.3.0", "rustix 0.38.21", @@ -261,6 +261,17 @@ dependencies = [ "event-listener 2.5.3", ] +[[package]] +name = "async-lock" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45e900cdcd39bb94a14487d3f7ef92ca222162e6c7c3fe7cb3550ea75fb486ed" +dependencies = [ + "event-listener 3.0.1", + "event-listener-strategy", + "pin-project-lite", +] + [[package]] name = "async-native-tls" version = "0.3.3" @@ -280,12 +291,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" dependencies = [ "async-io 1.13.0", - "async-lock", + "async-lock 2.8.0", "async-signal", "blocking", "cfg-if 1.0.0", "event-listener 3.0.1", - "futures-lite", + "futures-lite 1.13.0", "rustix 0.38.21", "windows-sys", ] @@ -297,7 +308,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07da4ce523b4e2ebaaf330746761df23a465b951a83d84bbce4233dabedae630" dependencies = [ "anyhow", - "async-lock", + "async-lock 2.8.0", "async-trait", "base64 0.13.1", "bincode", @@ -317,8 +328,8 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io 2.1.0", - "async-lock", + "async-io 2.2.0", + "async-lock 2.8.0", "atomic-waker", "cfg-if 1.0.0", "futures-core", @@ -348,13 +359,13 @@ dependencies = [ "async-channel", "async-global-executor", "async-io 1.13.0", - "async-lock", + "async-lock 2.8.0", "async-process", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-lite", + "futures-lite 1.13.0", "gloo-timers", "kv-log-macro", "log", @@ -380,7 +391,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -416,7 +427,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" version = "0.6.16" -source = "git+https://github.com/tokio-rs/axum?branch=main#d7258bf009194cf2f242694e673759d1dbf8cfc0" +source = "git+https://github.com/tokio-rs/axum?branch=main#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" dependencies = [ "async-trait", "axum-core 0.3.4 (git+https://github.com/tokio-rs/axum?branch=main)", @@ -501,7 +512,7 @@ dependencies = [ [[package]] name = "axum-core" version = "0.3.4" -source = "git+https://github.com/tokio-rs/axum?branch=main#d7258bf009194cf2f242694e673759d1dbf8cfc0" +source = "git+https://github.com/tokio-rs/axum?branch=main#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" dependencies = [ "async-trait", "bytes", @@ -519,7 +530,7 @@ dependencies = [ [[package]] name = "axum-extra" version = "0.7.4" -source = "git+https://github.com/tokio-rs/axum?branch=main#d7258bf009194cf2f242694e673759d1dbf8cfc0" +source = "git+https://github.com/tokio-rs/axum?branch=main#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" dependencies = [ "axum 0.6.16", "axum-core 0.3.4 (git+https://github.com/tokio-rs/axum?branch=main)", @@ -583,12 +594,12 @@ dependencies = [ [[package]] name = "axum-macros" version = "0.3.7" -source = "git+https://github.com/tokio-rs/axum?branch=main#d7258bf009194cf2f242694e673759d1dbf8cfc0" +source = "git+https://github.com/tokio-rs/axum?branch=main#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -600,7 +611,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -743,11 +754,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" dependencies = [ "async-channel", - "async-lock", + "async-lock 2.8.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite", + "futures-lite 1.13.0", "piper", "tracing", ] @@ -859,7 +870,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -952,7 +963,7 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" dependencies = [ - "crc-catalog 2.3.0", + "crc-catalog 2.4.0", ] [[package]] @@ -963,9 +974,9 @@ checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" [[package]] name = "crc-catalog" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4939f9ed1444bd8c896d37f3090012fa6e7834fe84ef8c9daa166109515732f9" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crossbeam-queue" @@ -1063,7 +1074,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -1093,7 +1104,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -1104,7 +1115,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -1189,9 +1200,9 @@ checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "dyn-clone" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ecdsa" @@ -1277,9 +1288,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" dependencies = [ "libc", "windows-sys", @@ -1313,6 +1324,16 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "event-listener-strategy" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +dependencies = [ + "event-listener 3.0.1", + "pin-project-lite", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -1340,9 +1361,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a481586acf778f1b1455424c343f71124b048ffa5f4fc3f8f6ae9dc432dcb3c7" +checksum = "f69037fe1b785e84986b4f2cbcf647381876a00671d25ceef715d7812dd7e1dd" [[package]] name = "finl_unicode" @@ -1482,6 +1503,16 @@ dependencies = [ "waker-fn", ] +[[package]] +name = "futures-lite" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" +dependencies = [ + "futures-core", + "pin-project-lite", +] + [[package]] name = "futures-macro" version = "0.3.29" @@ -1490,7 +1521,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -1536,9 +1567,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -1732,9 +1763,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "f95b9abcae896730d42b78e09c155ed4ddf82c07b4de772c64aee5b2d8b7c150" dependencies = [ "bytes", "fnv", @@ -2022,9 +2053,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.149" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libm" @@ -2032,6 +2063,17 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall 0.4.1", +] + [[package]] name = "libsqlite3-sys" version = "0.26.0" @@ -2051,9 +2093,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lock_api" @@ -2345,9 +2387,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.57" +version = "0.10.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" dependencies = [ "bitflags 2.4.1", "cfg-if 1.0.0", @@ -2366,7 +2408,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2377,9 +2419,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.93" +version = "0.9.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" dependencies = [ "cc", "libc", @@ -2528,7 +2570,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2653,9 +2695,9 @@ dependencies = [ [[package]] name = "primeorder" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2fcef82c0ec6eefcc179b978446c399b3cdf73c392c35604e399eee6df1ee3" +checksum = "c7dbe9ed3b56368bd99483eb32fe9c17fdd3730aebadc906918ce78d54c7eeb4" dependencies = [ "elliptic-curve", ] @@ -2734,12 +2776,12 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall 0.2.16", + "libredox", "thiserror", ] @@ -2909,7 +2951,7 @@ dependencies = [ "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.10", + "linux-raw-sys 0.4.11", "windows-sys", ] @@ -2927,9 +2969,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ "base64 0.21.5", ] @@ -3060,9 +3102,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] @@ -3079,13 +3121,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3156,7 +3198,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3256,9 +3298,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "socket2" @@ -3651,9 +3693,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -3717,7 +3759,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3776,9 +3818,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -3795,13 +3837,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3921,7 +3963,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -4123,7 +4165,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "wasm-bindgen-shared", ] @@ -4157,7 +4199,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4318,22 +4360,22 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.21" +version = "0.7.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686b7e407015242119c33dab17b8f61ba6843534de936d94368856528eae4dcc" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.21" +version = "0.7.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020f3dfe25dfc38dfea49ce62d5d45ecdd7f0d8a724fa63eb36b6eba4ec76806" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a789bb1..8fbf1b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,34 +5,40 @@ resolver = "2" [workspace.dependencies] nefarious-login = { path = "crates/nefarious-login" } -anyhow = { version = "1.0.75" } +anyhow = { version = "1" } tokio = { version = "1", features = ["full"] } tracing = { version = "0.1", features = ["log"] } -tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } +tracing-subscriber = { version = "0.3", features = ["env-filter"] } -clap = {version = "4.4.7", features = ["derive", "env"]} -async-trait = {version = "0.1.74", features = []} +clap = { version = "4", features = ["derive", "env"] } +async-trait = { version = "0.1", features = [] } -axum = { git = "https://github.com/tokio-rs/axum", branch = "main", features = ["macros"] } -axum-extra = {git = "https://github.com/tokio-rs/axum", branch = "main" , features = ["cookie", "cookie-private", "typed-header"]} -axum-sessions = {version = "0.6.1", features = []} -async-sqlx-session = {version = "0.4.0", features = ["pg"]} +axum = { git = "https://github.com/tokio-rs/axum", branch = "main", features = [ + "macros", +] } +axum-extra = { git = "https://github.com/tokio-rs/axum", branch = "main", features = [ + "cookie", + "cookie-private", + "typed-header", +] } +axum-sessions = { version = "0.6.1", features = [] } +async-sqlx-session = { version = "0.4.0", features = ["pg"] } -serde = {version = "1.0", features = ["derive"]} -serde_json = {version = "1.0.108"} +serde = { version = "1", features = ["derive"] } +serde_json = { version = "1" } -uuid = {version = "1.5.0", features = []} +uuid = { version = "1.5.0", features = [] } sqlx = { version = "0.7.2", features = [ "runtime-tokio-rustls", "postgres", "migrate", ] } -zitadel = { version = "3.4.29", features = ["axum"] } -tower = "0.4.13" -tower-http = { version = "0.4.4", features = ["cors", "trace"] } +zitadel = { version = "3.4", features = ["axum"] } +tower = "0.4" +tower-http = { version = "0.4", features = ["cors", "trace"] } oauth2 = "4.4.2" -openidconnect = "3.4.0" +openidconnect = "3.4" pretty_assertions = "1.4.0" sealed_test = "1.0.0" From 835cd32fb193ba3772de80eea4c4edfcfde8880a Mon Sep 17 00:00:00 2001 From: kjuulh Date: Fri, 10 Nov 2023 20:15:11 +0100 Subject: [PATCH 06/11] feat: update deps Signed-off-by: kjuulh --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8fbf1b5..c6bdf52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,10 +27,10 @@ async-sqlx-session = { version = "0.4.0", features = ["pg"] } serde = { version = "1", features = ["derive"] } serde_json = { version = "1" } -uuid = { version = "1.5.0", features = [] } -sqlx = { version = "0.7.2", features = [ - "runtime-tokio-rustls", - "postgres", +uuid = { version = "1.5", features = [] } +sqlx = { version = "0.7", features = [ +"runtime-tokio", + "postgres", "migrate", ] } From d4a162876a5df0a04634cc2a812f932c700ecfbd Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 12 Nov 2023 22:42:55 +0100 Subject: [PATCH 07/11] feat: with noop Signed-off-by: kjuulh --- Cargo.lock | 15 ++++ Cargo.toml | 6 +- crates/nefarious-login/src/auth.rs | 60 +++++++++++-- crates/nefarious-login/src/login/auth_clap.rs | 2 +- crates/nefarious-login/src/session.rs | 29 +++++-- examples/noop/Cargo.toml | 16 ++++ examples/noop/src/main.rs | 84 +++++++++++++++++++ 7 files changed, 193 insertions(+), 19 deletions(-) create mode 100644 examples/noop/Cargo.toml create mode 100644 examples/noop/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index d816021..d227cef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2233,6 +2233,18 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "noop" +version = "0.1.0" +dependencies = [ + "anyhow", + "axum 0.6.16", + "clap 4.4.7", + "nefarious-login", + "tokio", + "tracing-subscriber", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -4089,6 +4101,9 @@ name = "uuid" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +dependencies = [ + "getrandom", +] [[package]] name = "valuable" diff --git a/Cargo.toml b/Cargo.toml index c6bdf52..f5c2deb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,10 +27,10 @@ async-sqlx-session = { version = "0.4.0", features = ["pg"] } serde = { version = "1", features = ["derive"] } serde_json = { version = "1" } -uuid = { version = "1.5", features = [] } +uuid = {version = "1.5.0", features = ["v4"]} sqlx = { version = "0.7", features = [ -"runtime-tokio", - "postgres", + "runtime-tokio", + "postgres", "migrate", ] } diff --git a/crates/nefarious-login/src/auth.rs b/crates/nefarious-login/src/auth.rs index fbf7793..9e8c1c0 100644 --- a/crates/nefarious-login/src/auth.rs +++ b/crates/nefarious-login/src/auth.rs @@ -26,12 +26,17 @@ pub struct AuthService(Arc); impl AuthService { pub async fn new(config: &AuthClap) -> anyhow::Result { match config.engine { - AuthEngine::Noop => Ok(Self::new_noop()), + AuthEngine::Noop => { + let session = SessionService::new(config).await?; + + Ok(Self::new_noop(session, &config.config)) + } AuthEngine::Zitadel => { let session = SessionService::new(config).await?; let oauth: OAuth = ZitadelConfig::try_from(config.zitadel.clone())?.into(); let introspection: IntrospectionService = IntrospectionService::new_zitadel(config).await?; + Ok(Self::new_zitadel( oauth, introspection, @@ -56,8 +61,11 @@ impl AuthService { })) } - pub fn new_noop() -> Self { - Self(Arc::new(NoopAuthService {})) + pub fn new_noop(session: SessionService, config: &ConfigClap) -> Self { + Self(Arc::new(NoopAuthService { + session, + config: config.clone(), + })) } } @@ -111,26 +119,62 @@ impl Auth for ZitadelAuthService { } } -pub struct NoopAuthService {} +pub struct NoopAuthService { + session: SessionService, + config: ConfigClap, +} #[async_trait] impl Auth for NoopAuthService { async fn login(&self) -> anyhow::Result { - todo!() + let url = Url::parse(&format!( + "{}/auth/authorized?code=noop&state=noop", + self.config + .return_url + .rsplit_once('/') + .map(|(a, b)| a) + .unwrap() + )) + .unwrap(); + Ok(url) } async fn login_authorized( &self, _code: &str, _state: &str, ) -> anyhow::Result<(HeaderMap, Url)> { - todo!() + let cookie_value = self + .session + .insert_user( + "user", + IdToken { + sub: uuid::Uuid::new_v4().to_string(), + email: format!("{}@kjuulh.io", uuid::Uuid::new_v4()), + name: uuid::Uuid::new_v4().to_string(), + }, + ) + .await?; + + let cookie = format!("{}={}; SameSite=Lax; Path=/", COOKIE_NAME, cookie_value); + + let mut headers = HeaderMap::new(); + headers.insert(SET_COOKIE, cookie.parse().unwrap()); + + Ok(( + headers, + Url::parse(&self.config.return_url) + .context("failed to parse login_authorized zitadel return url")?, + )) } async fn login_token(&self, _user: &str, _password: &str) -> anyhow::Result { todo!() } - async fn get_user_from_session(&self, _cookie: &str) -> anyhow::Result { - todo!() + async fn get_user_from_session(&self, cookie: &str) -> anyhow::Result { + match self.session.get_user(cookie).await? { + Some(u) => Ok(u), + None => Err(anyhow::anyhow!("failed to find user")), + } } } diff --git a/crates/nefarious-login/src/login/auth_clap.rs b/crates/nefarious-login/src/login/auth_clap.rs index 4f2d6e1..5dfa4cd 100644 --- a/crates/nefarious-login/src/login/auth_clap.rs +++ b/crates/nefarious-login/src/login/auth_clap.rs @@ -15,7 +15,7 @@ pub struct AuthConfigFile { zitadel: Option, } -#[derive(clap::Args, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(clap::Args, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] #[group(requires_all = ["client_id", "client_secret", "redirect_url", "authority_url"])] pub struct ZitadelClap { #[arg(env = "ZITADEL_CLIENT_ID", long = "zitadel-client-id")] diff --git a/crates/nefarious-login/src/session.rs b/crates/nefarious-login/src/session.rs index 1667bc1..8db0793 100644 --- a/crates/nefarious-login/src/session.rs +++ b/crates/nefarious-login/src/session.rs @@ -19,7 +19,7 @@ pub struct SessionClap { pub postgresql: PostgresqlSessionClap, } -#[derive(clap::Args, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(clap::Args, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] pub struct PostgresqlSessionClap { #[arg(env = "SESSION_POSTGRES_CONN", long = "session-postgres-conn")] pub conn: Option, @@ -36,7 +36,7 @@ pub struct SessionService(Arc); impl SessionService { pub async fn new(config: &AuthClap) -> anyhow::Result { match config.session_backend { - SessionBackend::InMemory => Ok(Self(Arc::new(InMemorySessionService {}))), + SessionBackend::InMemory => Ok(Self(Arc::new(InMemorySessionService::default()))), SessionBackend::Postgresql => { let postgres_session = PostgresSessionStore::new( config @@ -119,15 +119,30 @@ impl Session for PostgresSessionService { } } -pub struct InMemorySessionService {} +#[derive(Default)] +pub struct InMemorySessionService { + store: std::sync::Mutex>, +} #[async_trait] impl Session for InMemorySessionService { - async fn insert_user(&self, _id: &str, _id_token: IdToken) -> anyhow::Result { - todo!() + async fn insert_user(&self, _id: &str, id_token: IdToken) -> anyhow::Result { + let user = User { + id: id_token.sub, + email: id_token.email, + name: id_token.name, + }; + + let id = uuid::Uuid::new_v4(); + + self.store.lock().unwrap().insert(id.to_string(), user); + + Ok(id.to_string()) } - async fn get_user(&self, _cookie: &str) -> anyhow::Result> { - todo!() + async fn get_user(&self, cookie: &str) -> anyhow::Result> { + let user = self.store.lock().unwrap().get(cookie).cloned(); + + Ok(user) } } diff --git a/examples/noop/Cargo.toml b/examples/noop/Cargo.toml new file mode 100644 index 0000000..7a6de43 --- /dev/null +++ b/examples/noop/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "noop" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +nefarious-login.workspace = true + +tokio.workspace = true +anyhow.workspace = true +axum.workspace = true +clap.workspace = true + +tracing-subscriber.workspace = true diff --git a/examples/noop/src/main.rs b/examples/noop/src/main.rs new file mode 100644 index 0000000..b64e808 --- /dev/null +++ b/examples/noop/src/main.rs @@ -0,0 +1,84 @@ +use std::{net::SocketAddr, str::FromStr}; + +use axum::{ + extract::{FromRef, State}, + response::IntoResponse, + routing::get, + Router, +}; +use nefarious_login::{ + auth::AuthService, + axum::{AuthController, UserFromSession}, + login::{ + auth_clap::{AuthEngine, ZitadelClap}, + config::ConfigClap, + AuthClap, + }, + session::{PostgresqlSessionClap, SessionBackend}, +}; +use tracing_subscriber::EnvFilter; + +#[derive(Clone)] +struct AppState { + auth: AuthService, +} + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .init(); + + let auth = AuthClap { + engine: AuthEngine::Noop, + session_backend: SessionBackend::InMemory, + zitadel: ZitadelClap { + ..Default::default() + }, + session: nefarious_login::session::SessionClap { + postgresql: PostgresqlSessionClap { + ..Default::default() + }, + }, + config: ConfigClap { + return_url: "http://localhost:3000/authed".into(), + }, + }; + + let auth_service = AuthService::new(&auth).await?; + + let state = AppState { + auth: auth_service.clone(), + }; + + let app = Router::new() + .route("/unauthed", get(unauthed)) + .route("/authed", get(authed)) + .with_state(state) + .nest("/auth", AuthController::new_router(auth_service).await?); + + let addr = SocketAddr::from_str(&format!("{}:{}", "127.0.0.1", "3000"))?; + let listener = tokio::net::TcpListener::bind(&addr).await?; + + axum::serve(listener, app).await?; + + Ok(()) +} + +impl FromRef for AuthService { + fn from_ref(input: &AppState) -> Self { + input.auth.clone() + } +} + +async fn unauthed() -> String { + "Hello Unauthorized User".into() +} + +#[axum::debug_handler()] +async fn authed( + user: UserFromSession, + State(_auth_service): State, +) -> impl IntoResponse { + format!("Hello authorized user: {:?}", user.user.id) +} From 6bf847a24a56f9c04c90e66c8cbaf414060cf0f5 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 21 Nov 2023 19:55:14 +0100 Subject: [PATCH 08/11] feat: minor update Signed-off-by: kjuulh --- Cargo.lock | 14 +------------- crates/nefarious-login/src/auth.rs | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d227cef..18d618f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2877,7 +2877,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.2", + "webpki-roots", "winreg", ] @@ -3481,8 +3481,6 @@ dependencies = [ "once_cell", "paste", "percent-encoding", - "rustls", - "rustls-pemfile", "serde", "serde_json", "sha2 0.10.8", @@ -3493,7 +3491,6 @@ dependencies = [ "tokio-stream", "tracing", "url", - "webpki-roots 0.24.0", ] [[package]] @@ -4235,15 +4232,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" -dependencies = [ - "rustls-webpki", -] - [[package]] name = "webpki-roots" version = "0.25.2" diff --git a/crates/nefarious-login/src/auth.rs b/crates/nefarious-login/src/auth.rs index 9e8c1c0..80cd561 100644 --- a/crates/nefarious-login/src/auth.rs +++ b/crates/nefarious-login/src/auth.rs @@ -132,7 +132,7 @@ impl Auth for NoopAuthService { self.config .return_url .rsplit_once('/') - .map(|(a, b)| a) + .map(|(a, _)| a) .unwrap() )) .unwrap(); From 9510b8fc42dd39cba0979baeb22ba3ab4ad3112b Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 21 Nov 2023 21:53:39 +0100 Subject: [PATCH 09/11] feat: with return url Signed-off-by: kjuulh --- Cargo.lock | 190 ++++++++++-------- crates/nefarious-login/src/auth.rs | 30 ++- crates/nefarious-login/src/axum.rs | 7 +- crates/nefarious-login/src/oauth.rs | 2 +- crates/nefarious-login/src/oauth/noop.rs | 2 +- crates/nefarious-login/src/oauth/zitadel.rs | 21 +- cuddle.yaml | 6 + examples/custom_redirect/Cargo.toml | 16 ++ examples/custom_redirect/src/main.rs | 94 +++++++++ scripts/local_down.sh | 7 + scripts/local_up.sh | 9 + .../docker-compose.local_up.dockerignore | 7 + templates/docker-compose.local_up.yml.tmpl | 17 ++ 13 files changed, 312 insertions(+), 96 deletions(-) create mode 100644 examples/custom_redirect/Cargo.toml create mode 100644 examples/custom_redirect/src/main.rs create mode 100755 scripts/local_down.sh create mode 100755 scripts/local_up.sh create mode 100644 templates/docker-compose.local_up.dockerignore create mode 100644 templates/docker-compose.local_up.yml.tmpl diff --git a/Cargo.lock b/Cargo.lock index 18d618f..4c8f0d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -184,16 +184,29 @@ dependencies = [ ] [[package]] -name = "async-executor" -version = "1.6.0" +name = "async-channel" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "d37875bd9915b7d67c2f117ea2c30a0989874d0b2cb694fe25403c85763c0c9e" dependencies = [ - "async-lock 2.8.0", + "concurrent-queue", + "event-listener 3.1.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc5ea910c42e5ab19012bab31f53cb4d63d54c3a27730f9a833a88efcf4bb52d" +dependencies = [ + "async-lock 3.1.1", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 1.13.0", + "futures-lite 2.0.1", "slab", ] @@ -203,7 +216,7 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" dependencies = [ - "async-channel", + "async-channel 1.9.0", "async-executor", "async-io 1.13.0", "async-lock 2.8.0", @@ -238,14 +251,14 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ - "async-lock 3.0.0", + "async-lock 3.1.1", "cfg-if 1.0.0", "concurrent-queue", "futures-io", "futures-lite 2.0.1", "parking", "polling 3.3.0", - "rustix 0.38.21", + "rustix 0.38.25", "slab", "tracing", "waker-fn", @@ -263,11 +276,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.0.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e900cdcd39bb94a14487d3f7ef92ca222162e6c7c3fe7cb3550ea75fb486ed" +checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" dependencies = [ - "event-listener 3.0.1", + "event-listener 3.1.0", "event-listener-strategy", "pin-project-lite", ] @@ -295,9 +308,9 @@ dependencies = [ "async-signal", "blocking", "cfg-if 1.0.0", - "event-listener 3.0.1", + "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.21", + "rustix 0.38.25", "windows-sys", ] @@ -334,7 +347,7 @@ dependencies = [ "cfg-if 1.0.0", "futures-core", "futures-io", - "rustix 0.38.21", + "rustix 0.38.25", "signal-hook-registry", "slab", "windows-sys", @@ -356,7 +369,7 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ - "async-channel", + "async-channel 1.9.0", "async-global-executor", "async-io 1.13.0", "async-lock 2.8.0", @@ -427,7 +440,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" version = "0.6.16" -source = "git+https://github.com/tokio-rs/axum?branch=main#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" +source = "git+https://github.com/tokio-rs/axum?branch=main#30afe97e99303fffc4bf2f411a93022b5bc1ba35" dependencies = [ "async-trait", "axum-core 0.3.4 (git+https://github.com/tokio-rs/axum?branch=main)", @@ -512,7 +525,7 @@ dependencies = [ [[package]] name = "axum-core" version = "0.3.4" -source = "git+https://github.com/tokio-rs/axum?branch=main#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" +source = "git+https://github.com/tokio-rs/axum?branch=main#30afe97e99303fffc4bf2f411a93022b5bc1ba35" dependencies = [ "async-trait", "bytes", @@ -530,7 +543,7 @@ dependencies = [ [[package]] name = "axum-extra" version = "0.7.4" -source = "git+https://github.com/tokio-rs/axum?branch=main#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" +source = "git+https://github.com/tokio-rs/axum?branch=main#30afe97e99303fffc4bf2f411a93022b5bc1ba35" dependencies = [ "axum 0.6.16", "axum-core 0.3.4 (git+https://github.com/tokio-rs/axum?branch=main)", @@ -594,7 +607,7 @@ dependencies = [ [[package]] name = "axum-macros" version = "0.3.7" -source = "git+https://github.com/tokio-rs/axum?branch=main#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" +source = "git+https://github.com/tokio-rs/axum?branch=main#30afe97e99303fffc4bf2f411a93022b5bc1ba35" dependencies = [ "heck", "proc-macro2", @@ -684,7 +697,7 @@ version = "0.1.0" dependencies = [ "anyhow", "axum 0.6.16", - "clap 4.4.7", + "clap 4.4.8", "nefarious-login", "tokio", "tracing-subscriber", @@ -749,16 +762,16 @@ dependencies = [ [[package]] name = "blocking" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel", - "async-lock 2.8.0", + "async-channel 2.1.0", + "async-lock 3.1.1", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite 1.13.0", + "futures-lite 2.0.1", "piper", "tracing", ] @@ -833,7 +846,7 @@ version = "0.1.0" dependencies = [ "anyhow", "axum 0.6.16", - "clap 4.4.7", + "clap 4.4.8", "nefarious-login", "tokio", "tracing-subscriber", @@ -841,9 +854,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", @@ -851,9 +864,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", @@ -999,9 +1012,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", "rand_core", @@ -1083,6 +1096,18 @@ version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f8a51dd197fa6ba5b4dc98a990a43cc13693c23eb0089ebb0fcc1f04152bca6" +[[package]] +name = "custom_redirect" +version = "0.1.0" +dependencies = [ + "anyhow", + "axum 0.6.16", + "clap 4.4.8", + "nefarious-login", + "tokio", + "tracing-subscriber", +] + [[package]] name = "darling" version = "0.20.3" @@ -1206,9 +1231,9 @@ checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest 0.10.7", @@ -1230,14 +1255,15 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" dependencies = [ "curve25519-dalek", "ed25519", "serde", "sha2 0.10.8", + "subtle", "zeroize", ] @@ -1252,9 +1278,9 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -1288,9 +1314,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", "windows-sys", @@ -1315,9 +1341,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cec0252c2afff729ee6f00e903d479fba81784c8e2bd77447673471fdfaea1" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" dependencies = [ "concurrent-queue", "parking", @@ -1330,7 +1356,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" dependencies = [ - "event-listener 3.0.1", + "event-listener 3.1.0", "pin-project-lite", ] @@ -1361,9 +1387,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f69037fe1b785e84986b4f2cbcf647381876a00671d25ceef715d7812dd7e1dd" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "finl_unicode" @@ -1509,7 +1535,11 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" dependencies = [ + "fastrand 2.0.1", "futures-core", + "futures-io", + "memchr", + "parking", "pin-project-lite", ] @@ -1619,9 +1649,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -1629,7 +1659,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -1763,9 +1793,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95b9abcae896730d42b78e09c155ed4ddf82c07b4de772c64aee5b2d8b7c150" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -2207,7 +2237,7 @@ dependencies = [ "axum 0.6.16", "axum-extra 0.7.4", "axum-sessions", - "clap 4.4.7", + "clap 4.4.8", "oauth2", "openidconnect", "pretty_assertions", @@ -2239,7 +2269,7 @@ version = "0.1.0" dependencies = [ "anyhow", "axum 0.6.16", - "clap 4.4.7", + "clap 4.4.8", "nefarious-login", "tokio", "tracing-subscriber", @@ -2666,7 +2696,7 @@ dependencies = [ "cfg-if 1.0.0", "concurrent-queue", "pin-project-lite", - "rustix 0.38.21", + "rustix 0.38.25", "tracing", "windows-sys", ] @@ -2707,9 +2737,9 @@ dependencies = [ [[package]] name = "primeorder" -version = "0.13.3" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7dbe9ed3b56368bd99483eb32fe9c17fdd3730aebadc906918ce78d54c7eeb4" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" dependencies = [ "elliptic-curve", ] @@ -2907,9 +2937,9 @@ dependencies = [ [[package]] name = "rsa" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ef35bf3e7fe15a53c4ab08a998e42271eab13eb0db224126bc7bc4c4bad96d" +checksum = "6a3211b01eea83d80687da9eef70e39d65144a3894866a5153a2723e425a157f" dependencies = [ "const-oid", "digest 0.10.7", @@ -2956,9 +2986,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", @@ -2969,9 +2999,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.8" +version = "0.21.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" +checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ "log", "ring", @@ -3114,9 +3144,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -3133,9 +3163,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -3279,9 +3309,9 @@ dependencies = [ [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", "rand_core", @@ -3747,7 +3777,7 @@ dependencies = [ "cfg-if 1.0.0", "fastrand 2.0.1", "redox_syscall 0.4.1", - "rustix 0.38.21", + "rustix 0.38.25", "windows-sys", ] @@ -3987,9 +4017,9 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ "log", "once_cell", @@ -3998,9 +4028,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -4095,9 +4125,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ "getrandom", ] @@ -4363,18 +4393,18 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.25" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.25" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" dependencies = [ "proc-macro2", "quote", @@ -4383,9 +4413,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" [[package]] name = "zitadel" diff --git a/crates/nefarious-login/src/auth.rs b/crates/nefarious-login/src/auth.rs index 80cd561..81b7b0f 100644 --- a/crates/nefarious-login/src/auth.rs +++ b/crates/nefarious-login/src/auth.rs @@ -14,9 +14,14 @@ use crate::{ #[async_trait] pub trait Auth { - async fn login(&self) -> anyhow::Result; + async fn login(&self, return_url: Option) -> anyhow::Result; async fn login_token(&self, user: &str, password: &str) -> anyhow::Result; - async fn login_authorized(&self, code: &str, state: &str) -> anyhow::Result<(HeaderMap, Url)>; + async fn login_authorized( + &self, + code: &str, + state: &str, + return_url: Option, + ) -> anyhow::Result<(HeaderMap, Url)>; async fn get_user_from_session(&self, cookie: &str) -> anyhow::Result; } @@ -87,12 +92,17 @@ pub static COOKIE_NAME: &str = "SESSION"; #[async_trait] impl Auth for ZitadelAuthService { - async fn login(&self) -> anyhow::Result { - let authorize_url = self.oauth.authorize_url().await?; + async fn login(&self, return_url: Option) -> anyhow::Result { + let authorize_url = self.oauth.authorize_url(return_url).await?; Ok(authorize_url) } - async fn login_authorized(&self, code: &str, _state: &str) -> anyhow::Result<(HeaderMap, Url)> { + async fn login_authorized( + &self, + code: &str, + _state: &str, + return_path: Option, + ) -> anyhow::Result<(HeaderMap, Url)> { let token = self.oauth.exchange(code).await?; let id_token = self.introspection.get_id_token(token.as_str()).await?; let cookie_value = self.session.insert_user("user", id_token).await?; @@ -102,9 +112,14 @@ impl Auth for ZitadelAuthService { let mut headers = HeaderMap::new(); headers.insert(SET_COOKIE, cookie.parse().unwrap()); + let mut return_url = self.config.return_url.clone(); + if let Some(return_path) = return_path { + return_url.push_str(&format!("?returnPath={return_path}")); + } + Ok(( headers, - Url::parse(&self.config.return_url) + Url::parse(&return_url) .context("failed to parse login_authorized zitadel return url")?, )) } @@ -126,7 +141,7 @@ pub struct NoopAuthService { #[async_trait] impl Auth for NoopAuthService { - async fn login(&self) -> anyhow::Result { + async fn login(&self, return_url: Option) -> anyhow::Result { let url = Url::parse(&format!( "{}/auth/authorized?code=noop&state=noop", self.config @@ -142,6 +157,7 @@ impl Auth for NoopAuthService { &self, _code: &str, _state: &str, + _return_url: Option, ) -> anyhow::Result<(HeaderMap, Url)> { let cookie_value = self .session diff --git a/crates/nefarious-login/src/axum.rs b/crates/nefarious-login/src/axum.rs index 73d0663..acb74d6 100644 --- a/crates/nefarious-login/src/axum.rs +++ b/crates/nefarious-login/src/axum.rs @@ -18,7 +18,6 @@ use crate::session::User; #[derive(Debug, Deserialize)] pub struct ZitadelAuthParams { - #[allow(dead_code)] return_url: Option, } @@ -51,7 +50,7 @@ where pub async fn zitadel_auth( State(auth_service): State, ) -> Result { - let url = auth_service.login().await.into_response()?; + let url = auth_service.login(None).await.into_response()?; Ok(Redirect::to(url.as_ref())) } @@ -61,6 +60,8 @@ pub async fn zitadel_auth( pub struct AuthRequest { code: String, state: String, + #[serde(alias = "returnUrl")] + return_url: Option, } pub async fn login_authorized( @@ -68,7 +69,7 @@ pub async fn login_authorized( State(auth_service): State, ) -> Result { let (headers, url) = auth_service - .login_authorized(&query.code, &query.state) + .login_authorized(&query.code, &query.state, query.return_url) .await .into_response()?; diff --git a/crates/nefarious-login/src/oauth.rs b/crates/nefarious-login/src/oauth.rs index bc0da8c..27059d8 100644 --- a/crates/nefarious-login/src/oauth.rs +++ b/crates/nefarious-login/src/oauth.rs @@ -31,7 +31,7 @@ impl Deref for OAuth { #[async_trait] pub trait OAuthClient { async fn get_token(&self) -> anyhow::Result<()>; - async fn authorize_url(&self) -> anyhow::Result; + async fn authorize_url(&self, return_url: Option) -> anyhow::Result; async fn exchange(&self, code: &str) -> anyhow::Result; } diff --git a/crates/nefarious-login/src/oauth/noop.rs b/crates/nefarious-login/src/oauth/noop.rs index 5d5432a..020779d 100644 --- a/crates/nefarious-login/src/oauth/noop.rs +++ b/crates/nefarious-login/src/oauth/noop.rs @@ -10,7 +10,7 @@ impl OAuthClient for NoopOAuthClient { async fn get_token(&self) -> anyhow::Result<()> { Ok(()) } - async fn authorize_url(&self) -> anyhow::Result { + async fn authorize_url(&self, return_url: Option) -> anyhow::Result { Ok(Url::parse("http://localhost:3000/auth/zitadel").unwrap()) } diff --git a/crates/nefarious-login/src/oauth/zitadel.rs b/crates/nefarious-login/src/oauth/zitadel.rs index d889494..a144157 100644 --- a/crates/nefarious-login/src/oauth/zitadel.rs +++ b/crates/nefarious-login/src/oauth/zitadel.rs @@ -104,15 +104,28 @@ impl OAuthClient for ZitadelOAuthClient { async fn get_token(&self) -> anyhow::Result<()> { Ok(()) } - async fn authorize_url(&self) -> anyhow::Result { - let (auth_url, _csrf_token) = self + async fn authorize_url(&self, return_url: Option) -> anyhow::Result { + let req = self .client .authorize_url(CsrfToken::new_random) .add_scope(Scope::new("identify".to_string())) .add_scope(Scope::new("openid".to_string())) .add_scope(Scope::new("email".to_string())) - .add_scope(Scope::new("profile".to_string())) - .url(); + .add_scope(Scope::new("profile".to_string())); + + let req = { + if let Some(return_url) = return_url { + let mut redirect_url = self.client.redirect_url().unwrap().as_str().to_string(); + + redirect_url.push_str(&format!("?returnUrl={}", return_url)); + + req.set_redirect_uri(std::borrow::Cow::Owned(RedirectUrl::new(redirect_url)?)) + } else { + req + } + }; + + let (auth_url, _csrf_token) = req.url(); Ok(auth_url) } diff --git a/cuddle.yaml b/cuddle.yaml index 246a8fd..7dfc989 100644 --- a/cuddle.yaml +++ b/cuddle.yaml @@ -5,3 +5,9 @@ base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git" vars: service: "nefarious-login" registry: kasperhermansen + +scripts: + local_up: + type: shell + local_down: + type: shell diff --git a/examples/custom_redirect/Cargo.toml b/examples/custom_redirect/Cargo.toml new file mode 100644 index 0000000..299c651 --- /dev/null +++ b/examples/custom_redirect/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "custom_redirect" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +nefarious-login.workspace = true + +tokio.workspace = true +anyhow.workspace = true +axum.workspace = true +clap.workspace = true + +tracing-subscriber.workspace = true diff --git a/examples/custom_redirect/src/main.rs b/examples/custom_redirect/src/main.rs new file mode 100644 index 0000000..a5a13bb --- /dev/null +++ b/examples/custom_redirect/src/main.rs @@ -0,0 +1,94 @@ +use std::{net::SocketAddr, str::FromStr}; + +use axum::{ + extract::{FromRef, State}, + response::{IntoResponse, Redirect}, + routing::get, + Router, +}; +use nefarious_login::{ + auth::AuthService, + axum::{AuthController, UserFromSession}, + login::{ + auth_clap::{AuthEngine, ZitadelClap}, + config::ConfigClap, + AuthClap, + }, + session::{PostgresqlSessionClap, SessionBackend}, +}; +use tracing_subscriber::EnvFilter; + +#[derive(Clone)] +struct AppState { + auth: AuthService, +} + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .init(); + + let auth = AuthClap { + engine: AuthEngine::Zitadel, + session_backend: SessionBackend::Postgresql, + zitadel: ZitadelClap { + authority_url: Some("https://personal-wxuujs.zitadel.cloud".into()), + client_id: Some("237412977047895154@nefarious-test".into()), + client_secret: Some( + "rWwDi8gjNOyuMFKoOjNSlhjcVZ1B25wDh6HsDL27f0g2Hb0xGbvEf0WXFY2akOlL".into(), + ), + redirect_url: Some("http://localhost:3001/auth/authorized".into()), + }, + session: nefarious_login::session::SessionClap { + postgresql: PostgresqlSessionClap { + conn: Some("postgres://nefarious-test:somenotverysecurepassword@localhost:5432/nefarious-test".into()), + }, + }, + config: ConfigClap { return_url: "http://localhost:3001".into() } // this normally has /authed + }; + + let auth_service = AuthService::new(&auth).await?; + + let state = AppState { + auth: auth_service.clone(), + }; + + let app = Router::new() + .route("/unauthed", get(unauthed)) + .route("/authed", get(authed)) + .route("/login", get(login)) + .with_state(state) + .nest("/auth", AuthController::new_router(auth_service).await?); + + let addr = SocketAddr::from_str(&format!("{}:{}", "127.0.0.1", "3000"))?; + let listener = tokio::net::TcpListener::bind(&addr).await?; + + axum::serve(listener, app).await?; + + Ok(()) +} + +impl FromRef for AuthService { + fn from_ref(input: &AppState) -> Self { + input.auth.clone() + } +} + +async fn login(State(auth_service): State) -> impl IntoResponse { + let url = auth_service.login(Some("/authed".into())).await.unwrap(); + + Redirect::to(url.as_ref()) +} + +async fn unauthed() -> String { + "Hello Unauthorized User".into() +} + +#[axum::debug_handler()] +async fn authed( + user: UserFromSession, + State(_auth_service): State, +) -> impl IntoResponse { + format!("Hello authorized user: {:?}", user.user.id) +} diff --git a/scripts/local_down.sh b/scripts/local_down.sh new file mode 100755 index 0000000..cbb90a3 --- /dev/null +++ b/scripts/local_down.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +cuddle render_template --template-file $TMP/docker-compose.local_up.yml.tmpl --dest $TMP/docker-compose.local_up.yml + +docker compose -f $TMP/docker-compose.local_up.yml down -v diff --git a/scripts/local_up.sh b/scripts/local_up.sh new file mode 100755 index 0000000..d215338 --- /dev/null +++ b/scripts/local_up.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +cuddle render_template --template-file $TMP/docker-compose.local_up.yml.tmpl --dest $TMP/docker-compose.local_up.yml + +docker compose -f $TMP/docker-compose.local_up.yml up -d --remove-orphans --build + +sleep 3 diff --git a/templates/docker-compose.local_up.dockerignore b/templates/docker-compose.local_up.dockerignore new file mode 100644 index 0000000..53f730a --- /dev/null +++ b/templates/docker-compose.local_up.dockerignore @@ -0,0 +1,7 @@ +target/ +.git/ +.cuddle/ +scripts/ +cuddle.yaml +local.sh +README.md diff --git a/templates/docker-compose.local_up.yml.tmpl b/templates/docker-compose.local_up.yml.tmpl new file mode 100644 index 0000000..5760c45 --- /dev/null +++ b/templates/docker-compose.local_up.yml.tmpl @@ -0,0 +1,17 @@ +version: '3.7' + +services: + db: + image: bitnami/postgresql:16 + restart: always + environment: + - POSTGRESQL_USERNAME=nefarious-test + - POSTGRESQL_DATABASE=nefarious-test + - POSTGRESQL_PASSWORD=somenotverysecurepassword + ports: + - 5432:5432 + volumes: + - pgdata:/var/lib/postgresql/data + +volumes: + pgdata: From 92e435e0806ec41c29c7527035ef196d9ffd3c39 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 21 Nov 2023 22:52:22 +0100 Subject: [PATCH 10/11] feat: with return url Signed-off-by: kjuulh --- crates/nefarious-login/src/auth.rs | 44 +++++++++++++++------ crates/nefarious-login/src/axum.rs | 16 +++++--- crates/nefarious-login/src/oauth.rs | 2 +- crates/nefarious-login/src/oauth/noop.rs | 2 +- crates/nefarious-login/src/oauth/zitadel.rs | 14 +------ crates/nefarious-login/src/session.rs | 39 +++++++++++++++++- examples/custom_redirect/src/main.rs | 6 +-- 7 files changed, 86 insertions(+), 37 deletions(-) diff --git a/crates/nefarious-login/src/auth.rs b/crates/nefarious-login/src/auth.rs index 81b7b0f..8099610 100644 --- a/crates/nefarious-login/src/auth.rs +++ b/crates/nefarious-login/src/auth.rs @@ -9,18 +9,18 @@ use crate::{ introspection::{IdToken, IntrospectionService}, login::{auth_clap::AuthEngine, config::ConfigClap, AuthClap}, oauth::{zitadel::ZitadelConfig, OAuth}, - session::{SessionService, User}, + session::{AppSession, SessionService, User}, }; #[async_trait] pub trait Auth { - async fn login(&self, return_url: Option) -> anyhow::Result; + async fn login(&self, return_url: Option) -> anyhow::Result<(HeaderMap, Url)>; async fn login_token(&self, user: &str, password: &str) -> anyhow::Result; async fn login_authorized( &self, code: &str, state: &str, - return_url: Option, + app_session_cookie: Option, ) -> anyhow::Result<(HeaderMap, Url)>; async fn get_user_from_session(&self, cookie: &str) -> anyhow::Result; } @@ -89,19 +89,31 @@ pub struct ZitadelAuthService { config: ConfigClap, } pub static COOKIE_NAME: &str = "SESSION"; +pub static COOKIE_APP_SESSION_NAME: &str = "APP_SESSION"; #[async_trait] impl Auth for ZitadelAuthService { - async fn login(&self, return_url: Option) -> anyhow::Result { - let authorize_url = self.oauth.authorize_url(return_url).await?; + async fn login(&self, return_url: Option) -> anyhow::Result<(HeaderMap, Url)> { + let mut headers = HeaderMap::new(); + if let Some(return_url) = return_url.clone() { + let cookie_value = self.session.insert(AppSession { return_url }).await?; - Ok(authorize_url) + let cookie = format!( + "{}={}; SameSite=Lax; Path=/", + COOKIE_APP_SESSION_NAME, cookie_value + ); + headers.insert(SET_COOKIE, cookie.parse().unwrap()); + } + + let authorize_url = self.oauth.authorize_url().await?; + + Ok((headers, authorize_url)) } async fn login_authorized( &self, code: &str, _state: &str, - return_path: Option, + app_session_cookie: Option, ) -> anyhow::Result<(HeaderMap, Url)> { let token = self.oauth.exchange(code).await?; let id_token = self.introspection.get_id_token(token.as_str()).await?; @@ -113,8 +125,16 @@ impl Auth for ZitadelAuthService { headers.insert(SET_COOKIE, cookie.parse().unwrap()); let mut return_url = self.config.return_url.clone(); - if let Some(return_path) = return_path { - return_url.push_str(&format!("?returnPath={return_path}")); + if let Some(cookie) = app_session_cookie { + if let Some(session) = self.session.get(&cookie).await? { + if session.return_url.starts_with('/') { + let mut url = Url::parse(&return_url)?; + url.set_path(&session.return_url); + return_url = url.to_string(); + } else { + return_url = session.return_url; + } + } } Ok(( @@ -141,7 +161,7 @@ pub struct NoopAuthService { #[async_trait] impl Auth for NoopAuthService { - async fn login(&self, return_url: Option) -> anyhow::Result { + async fn login(&self, return_url: Option) -> anyhow::Result<(HeaderMap, Url)> { let url = Url::parse(&format!( "{}/auth/authorized?code=noop&state=noop", self.config @@ -151,13 +171,13 @@ impl Auth for NoopAuthService { .unwrap() )) .unwrap(); - Ok(url) + Ok((HeaderMap::new(), url)) } async fn login_authorized( &self, _code: &str, _state: &str, - _return_url: Option, + _app_session_cookie: Option, ) -> anyhow::Result<(HeaderMap, Url)> { let cookie_value = self .session diff --git a/crates/nefarious-login/src/axum.rs b/crates/nefarious-login/src/axum.rs index acb74d6..424f067 100644 --- a/crates/nefarious-login/src/axum.rs +++ b/crates/nefarious-login/src/axum.rs @@ -7,13 +7,14 @@ use axum::response::{ErrorResponse, IntoResponse, Redirect}; use axum::routing::get; use axum::{async_trait, Json, RequestPartsExt, Router}; +use axum_extra::extract::CookieJar; use axum_extra::headers::authorization::Basic; use axum_extra::headers::{Authorization, Cookie}; use axum_extra::TypedHeader; use serde::Deserialize; use serde_json::json; -use crate::auth::AuthService; +use crate::auth::{AuthService, COOKIE_APP_SESSION_NAME}; use crate::session::User; #[derive(Debug, Deserialize)] @@ -50,9 +51,9 @@ where pub async fn zitadel_auth( State(auth_service): State, ) -> Result { - let url = auth_service.login(None).await.into_response()?; + let (headers, url) = auth_service.login(None).await.into_response()?; - Ok(Redirect::to(url.as_ref())) + Ok((headers, Redirect::to(url.as_ref()))) } #[derive(Debug, Deserialize)] @@ -60,16 +61,19 @@ pub async fn zitadel_auth( pub struct AuthRequest { code: String, state: String, - #[serde(alias = "returnUrl")] - return_url: Option, } pub async fn login_authorized( Query(query): Query, State(auth_service): State, + cookie_jar: CookieJar, ) -> Result { + let cookie_value = cookie_jar + .get(COOKIE_APP_SESSION_NAME) + .map(|c| c.value().to_string()); + let (headers, url) = auth_service - .login_authorized(&query.code, &query.state, query.return_url) + .login_authorized(&query.code, &query.state, cookie_value) .await .into_response()?; diff --git a/crates/nefarious-login/src/oauth.rs b/crates/nefarious-login/src/oauth.rs index 27059d8..bc0da8c 100644 --- a/crates/nefarious-login/src/oauth.rs +++ b/crates/nefarious-login/src/oauth.rs @@ -31,7 +31,7 @@ impl Deref for OAuth { #[async_trait] pub trait OAuthClient { async fn get_token(&self) -> anyhow::Result<()>; - async fn authorize_url(&self, return_url: Option) -> anyhow::Result; + async fn authorize_url(&self) -> anyhow::Result; async fn exchange(&self, code: &str) -> anyhow::Result; } diff --git a/crates/nefarious-login/src/oauth/noop.rs b/crates/nefarious-login/src/oauth/noop.rs index 020779d..5d5432a 100644 --- a/crates/nefarious-login/src/oauth/noop.rs +++ b/crates/nefarious-login/src/oauth/noop.rs @@ -10,7 +10,7 @@ impl OAuthClient for NoopOAuthClient { async fn get_token(&self) -> anyhow::Result<()> { Ok(()) } - async fn authorize_url(&self, return_url: Option) -> anyhow::Result { + async fn authorize_url(&self) -> anyhow::Result { Ok(Url::parse("http://localhost:3000/auth/zitadel").unwrap()) } diff --git a/crates/nefarious-login/src/oauth/zitadel.rs b/crates/nefarious-login/src/oauth/zitadel.rs index a144157..5daf5e8 100644 --- a/crates/nefarious-login/src/oauth/zitadel.rs +++ b/crates/nefarious-login/src/oauth/zitadel.rs @@ -104,7 +104,7 @@ impl OAuthClient for ZitadelOAuthClient { async fn get_token(&self) -> anyhow::Result<()> { Ok(()) } - async fn authorize_url(&self, return_url: Option) -> anyhow::Result { + async fn authorize_url(&self) -> anyhow::Result { let req = self .client .authorize_url(CsrfToken::new_random) @@ -113,18 +113,6 @@ impl OAuthClient for ZitadelOAuthClient { .add_scope(Scope::new("email".to_string())) .add_scope(Scope::new("profile".to_string())); - let req = { - if let Some(return_url) = return_url { - let mut redirect_url = self.client.redirect_url().unwrap().as_str().to_string(); - - redirect_url.push_str(&format!("?returnUrl={}", return_url)); - - req.set_redirect_uri(std::borrow::Cow::Owned(RedirectUrl::new(redirect_url)?)) - } else { - req - } - }; - let (auth_url, _csrf_token) = req.url(); Ok(auth_url) diff --git a/crates/nefarious-login/src/session.rs b/crates/nefarious-login/src/session.rs index 8db0793..86083a5 100644 --- a/crates/nefarious-login/src/session.rs +++ b/crates/nefarious-login/src/session.rs @@ -27,12 +27,13 @@ pub struct PostgresqlSessionClap { #[async_trait] pub trait Session { + async fn insert(&self, app_session: AppSession) -> anyhow::Result; async fn insert_user(&self, id: &str, id_token: IdToken) -> anyhow::Result; async fn get_user(&self, cookie: &str) -> anyhow::Result>; + async fn get(&self, cookie: &str) -> anyhow::Result>; } pub struct SessionService(Arc); - impl SessionService { pub async fn new(config: &AuthClap) -> anyhow::Result { match config.session_backend { @@ -77,8 +78,26 @@ pub struct User { pub name: String, } +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct AppSession { + pub return_url: String, +} + #[async_trait] impl Session for PostgresSessionService { + async fn insert(&self, app_session: AppSession) -> anyhow::Result { + let mut session = AxumSession::new(); + session.insert("app_session", app_session)?; + + let cookie = self + .store + .store_session(session) + .await? + .ok_or(anyhow::anyhow!("failed to store app session"))?; + + Ok(cookie) + } + async fn insert_user(&self, _id: &str, id_token: IdToken) -> anyhow::Result { let mut session = AxumSession::new(); session.insert( @@ -117,6 +136,18 @@ impl Session for PostgresSessionService { Err(anyhow::anyhow!("No session found for cookie")) } } + + async fn get(&self, cookie: &str) -> anyhow::Result> { + let Some(session) = self.store.load_session(cookie.to_string()).await? else { + return Ok(None); + }; + + let Some(session) = session.get::("app_session") else { + anyhow::bail!("failed to deserialize app_session from cookie"); + }; + + Ok(Some(session)) + } } #[derive(Default)] @@ -126,6 +157,9 @@ pub struct InMemorySessionService { #[async_trait] impl Session for InMemorySessionService { + async fn insert(&self, app_session: AppSession) -> anyhow::Result { + todo!() + } async fn insert_user(&self, _id: &str, id_token: IdToken) -> anyhow::Result { let user = User { id: id_token.sub, @@ -145,4 +179,7 @@ impl Session for InMemorySessionService { Ok(user) } + async fn get(&self, cookie: &str) -> anyhow::Result> { + todo!() + } } diff --git a/examples/custom_redirect/src/main.rs b/examples/custom_redirect/src/main.rs index a5a13bb..5ad4d07 100644 --- a/examples/custom_redirect/src/main.rs +++ b/examples/custom_redirect/src/main.rs @@ -45,7 +45,7 @@ async fn main() -> anyhow::Result<()> { conn: Some("postgres://nefarious-test:somenotverysecurepassword@localhost:5432/nefarious-test".into()), }, }, - config: ConfigClap { return_url: "http://localhost:3001".into() } // this normally has /authed + config: ConfigClap { return_url: "http://localhost:3001/authed".into() } // this normally has /authed }; let auth_service = AuthService::new(&auth).await?; @@ -76,9 +76,9 @@ impl FromRef for AuthService { } async fn login(State(auth_service): State) -> impl IntoResponse { - let url = auth_service.login(Some("/authed".into())).await.unwrap(); + let (headers, url) = auth_service.login(Some("/authed".into())).await.unwrap(); - Redirect::to(url.as_ref()) + (headers, Redirect::to(url.as_ref())) } async fn unauthed() -> String { From 66080374b0d3525041fbf577e5a0a1137656102a Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 28 Nov 2023 11:44:53 +0100 Subject: [PATCH 11/11] feat: with upstream axum Signed-off-by: kjuulh --- Cargo.lock | 646 ++++++++++++++++++++++++++++++++++------------------- Cargo.toml | 4 +- 2 files changed, 412 insertions(+), 238 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c8f0d8..385961c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,7 +141,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -151,7 +151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -185,12 +185,12 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d37875bd9915b7d67c2f117ea2c30a0989874d0b2cb694fe25403c85763c0c9e" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" dependencies = [ "concurrent-queue", - "event-listener 3.1.0", + "event-listener 4.0.0", "event-listener-strategy", "futures-core", "pin-project-lite", @@ -198,11 +198,11 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc5ea910c42e5ab19012bab31f53cb4d63d54c3a27730f9a833a88efcf4bb52d" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock 3.1.1", + "async-lock 3.1.2", "async-task", "concurrent-queue", "fastrand 2.0.1", @@ -212,16 +212,16 @@ dependencies = [ [[package]] name = "async-global-executor" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +checksum = "9b4353121d5644cdf2beb5726ab752e79a8db1ebb52031770ec47db31d245526" dependencies = [ - "async-channel 1.9.0", + "async-channel 2.1.1", "async-executor", - "async-io 1.13.0", - "async-lock 2.8.0", + "async-io 2.2.1", + "async-lock 3.1.2", "blocking", - "futures-lite 1.13.0", + "futures-lite 2.0.1", "once_cell", ] @@ -247,22 +247,21 @@ dependencies = [ [[package]] name = "async-io" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" +checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" dependencies = [ - "async-lock 3.1.1", + "async-lock 3.1.2", "cfg-if 1.0.0", "concurrent-queue", "futures-io", "futures-lite 2.0.1", "parking", - "polling 3.3.0", + "polling 3.3.1", "rustix 0.38.25", "slab", "tracing", - "waker-fn", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -276,11 +275,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.1.1" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" +checksum = "dea8b3453dd7cc96711834b75400d671b73e3656975fa68d9f277163b7f7e316" dependencies = [ - "event-listener 3.1.0", + "event-listener 4.0.0", "event-listener-strategy", "pin-project-lite", ] @@ -311,7 +310,7 @@ dependencies = [ "event-listener 3.1.0", "futures-lite 1.13.0", "rustix 0.38.25", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -341,7 +340,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io 2.2.0", + "async-io 2.2.1", "async-lock 2.8.0", "atomic-waker", "cfg-if 1.0.0", @@ -350,7 +349,7 @@ dependencies = [ "rustix 0.38.25", "signal-hook-registry", "slab", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -431,6 +430,16 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atomic-write-file" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae364a6c1301604bbc6dfbf8c385c47ff82301dd01eef506195a029196d8d04" +dependencies = [ + "nix", + "rand", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -439,19 +448,20 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.16" -source = "git+https://github.com/tokio-rs/axum?branch=main#30afe97e99303fffc4bf2f411a93022b5bc1ba35" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core 0.3.4 (git+https://github.com/tokio-rs/axum?branch=main)", - "axum-macros 0.3.7", + "axum-core 0.3.4", + "axum-macros 0.3.8", + "bitflags 1.3.2", "bytes", "futures-util", - "http", + "headers 0.3.9", + "http 0.2.11", "http-body 0.4.5", "hyper 0.14.27", - "hyper 1.0.0-rc.4", - "hyper-util", "itoa", "matchit", "memchr", @@ -466,27 +476,26 @@ dependencies = [ "sync_wrapper", "tokio", "tower", - "tower-hyper-http-body-compat", "tower-layer", "tower-service", ] [[package]] name = "axum" -version = "0.6.20" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "810a80b128d70e6ed2bdf3fe8ed72c0ae56f5f5948d01c2753282dd92a84fce8" dependencies = [ "async-trait", - "axum-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "axum-macros 0.3.8", - "bitflags 1.3.2", + "axum-core 0.4.0", + "axum-macros 0.4.0", "bytes", "futures-util", - "headers", - "http", - "http-body 0.4.5", - "hyper 0.14.27", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.0.1", + "hyper-util", "itoa", "matchit", "memchr", @@ -514,7 +523,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", + "http 0.2.11", "http-body 0.4.5", "mime", "rustversion", @@ -524,14 +533,16 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" -source = "git+https://github.com/tokio-rs/axum?branch=main#30afe97e99303fffc4bf2f411a93022b5bc1ba35" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0ddc355eab88f4955090a823715df47acf0b7660aab7a69ad5ce6301ee3b73" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body 0.4.5", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "mime", "pin-project-lite", "rustversion", @@ -540,27 +551,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "axum-extra" -version = "0.7.4" -source = "git+https://github.com/tokio-rs/axum?branch=main#30afe97e99303fffc4bf2f411a93022b5bc1ba35" -dependencies = [ - "axum 0.6.16", - "axum-core 0.3.4 (git+https://github.com/tokio-rs/axum?branch=main)", - "bytes", - "cookie", - "futures-util", - "headers", - "http", - "http-body 0.4.5", - "mime", - "pin-project-lite", - "serde", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "axum-extra" version = "0.7.7" @@ -568,11 +558,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a93e433be9382c737320af3924f7d5fc6f89c155cf2bf88949d8f5126fab283f" dependencies = [ "axum 0.6.20", - "axum-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "axum-core 0.3.4", "bytes", - "cookie", + "cookie 0.17.0", "futures-util", - "http", + "http 0.2.11", "http-body 0.4.5", "mime", "pin-project-lite", @@ -590,10 +580,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ab90e7b70bea63a153137162affb6a0bce26b584c24a4c7885509783e2cf30b" dependencies = [ "axum 0.6.20", - "axum-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "axum-core 0.3.4", "bytes", "futures-util", - "http", + "http 0.2.11", "http-body 0.4.5", "mime", "pin-project-lite", @@ -604,10 +594,34 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-extra" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523ae92256049a3b02d3bb4df80152386cd97ddba0c8c5077619bdc8c4b1859b" +dependencies = [ + "axum 0.7.1", + "axum-core 0.4.0", + "bytes", + "cookie 0.18.0", + "futures-util", + "headers 0.4.0", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "mime", + "pin-project-lite", + "serde", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "axum-macros" -version = "0.3.7" -source = "git+https://github.com/tokio-rs/axum?branch=main#30afe97e99303fffc4bf2f411a93022b5bc1ba35" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdca6a10ecad987bda04e95606ef85a5417dcaac1a78455242d72e031e2b6b62" dependencies = [ "heck", "proc-macro2", @@ -617,9 +631,9 @@ dependencies = [ [[package]] name = "axum-macros" -version = "0.3.8" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdca6a10ecad987bda04e95606ef85a5417dcaac1a78455242d72e031e2b6b62" +checksum = "5a2edad600410b905404c594e2523549f1bcd4bded1e252c8f74524ccce0b867" dependencies = [ "heck", "proc-macro2", @@ -696,8 +710,8 @@ name = "basic" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.6.16", - "clap 4.4.8", + "axum 0.7.1", + "clap 4.4.10", "nefarious-login", "tokio", "tracing-subscriber", @@ -766,8 +780,8 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.1.0", - "async-lock 3.1.1", + "async-channel 2.1.1", + "async-lock 3.1.2", "async-task", "fastrand 2.0.1", "futures-io", @@ -827,7 +841,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -845,8 +859,8 @@ name = "clap" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.6.16", - "clap 4.4.8", + "axum 0.7.1", + "clap 4.4.10", "nefarious-login", "tokio", "tracing-subscriber", @@ -854,9 +868,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.8" +version = "4.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" dependencies = [ "clap_builder", "clap_derive", @@ -864,9 +878,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" dependencies = [ "anstream", "anstyle", @@ -925,7 +939,6 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" dependencies = [ - "aes-gcm", "base64 0.21.5", "hmac 0.12.1", "percent-encoding", @@ -936,6 +949,21 @@ dependencies = [ "version_check", ] +[[package]] +name = "cookie" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8" +dependencies = [ + "aes-gcm", + "base64 0.21.5", + "percent-encoding", + "rand", + "subtle", + "time", + "version_check", +] + [[package]] name = "core-foundation" version = "0.9.3" @@ -1101,8 +1129,8 @@ name = "custom_redirect" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.6.16", - "clap 4.4.8", + "axum 0.7.1", + "clap 4.4.10", "nefarious-login", "tokio", "tracing-subscriber", @@ -1314,12 +1342,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1330,7 +1358,7 @@ checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" dependencies = [ "cfg-if 1.0.0", "home", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1351,12 +1379,23 @@ dependencies = [ ] [[package]] -name = "event-listener-strategy" -version = "0.3.0" +name = "event-listener" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" dependencies = [ - "event-listener 3.1.0", + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.0", "pin-project-lite", ] @@ -1431,9 +1470,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1620,9 +1659,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gloo-timers" @@ -1658,7 +1697,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.11", + "indexmap 2.1.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d308f63daf4181410c242d34c11f928dcb3aa105852019e043c9d1f4e4368a" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", "indexmap 2.1.0", "slab", "tokio", @@ -1683,9 +1741,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash 0.8.6", "allocator-api2", @@ -1706,7 +1764,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.14.2", + "hashbrown 0.14.3", ] [[package]] @@ -1717,8 +1775,23 @@ checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ "base64 0.21.5", "bytes", - "headers-core", - "http", + "headers-core 0.2.0", + "http 0.2.11", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" +dependencies = [ + "base64 0.21.5", + "bytes", + "headers-core 0.3.0", + "http 1.0.0", "httpdate", "mime", "sha1", @@ -1730,7 +1803,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http", + "http 0.2.11", +] + +[[package]] +name = "headers-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" +dependencies = [ + "http 1.0.0", ] [[package]] @@ -1788,7 +1870,7 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1802,6 +1884,17 @@ dependencies = [ "itoa", ] +[[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.5" @@ -1809,18 +1902,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.11", "pin-project-lite", ] [[package]] name = "http-body" -version = "1.0.0-rc.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951dfc2e32ac02d67c90c0d65bd27009a635dc9b381a2cc7d284ab01e3a0150d" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ "bytes", - "http", + "http 1.0.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "pin-project-lite", ] [[package]] @@ -1851,8 +1957,8 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", + "h2 0.3.22", + "http 0.2.11", "http-body 0.4.5", "httparse", "httpdate", @@ -1867,23 +1973,21 @@ dependencies = [ [[package]] name = "hyper" -version = "1.0.0-rc.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d280a71f348bcc670fc55b02b63c53a04ac0bf2daff2980795aeaf53edae10e6" +checksum = "403f9214f3e703236b221f1a9cd88ec8b4adfa5296de01ab96216361f4692f56" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2", - "http", - "http-body 1.0.0-rc.2", + "h2 0.4.0", + "http 1.0.0", + "http-body 1.0.0", "httparse", "httpdate", "itoa", "pin-project-lite", "tokio", - "tracing", - "want", ] [[package]] @@ -1893,7 +1997,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", + "http 0.2.11", "hyper 0.14.27", "rustls", "tokio", @@ -1902,16 +2006,16 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.0.0" -source = "git+https://github.com/hyperium/hyper-util?rev=d97181a#d97181a278d9c59f1d7f2713732e400440861216" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca339002caeb0d159cc6e023dff48e199f081e42fa039895c7c6f38b37f2e9d" dependencies = [ "bytes", "futures-channel", "futures-util", - "http", - "http-body 1.0.0-rc.2", - "hyper 1.0.0-rc.4", - "once_cell", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.0.1", "pin-project-lite", "socket2 0.5.5", "tokio", @@ -1951,9 +2055,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[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", @@ -1977,7 +2081,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "serde", ] @@ -2007,7 +2111,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2042,9 +2146,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -2106,9 +2210,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" dependencies = [ "cc", "pkg-config", @@ -2206,7 +2310,7 @@ checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2234,17 +2338,17 @@ dependencies = [ "anyhow", "async-sqlx-session", "async-trait", - "axum 0.6.16", - "axum-extra 0.7.4", + "axum 0.7.1", + "axum-extra 0.9.0", "axum-sessions", - "clap 4.4.8", + "clap 4.4.10", "oauth2", "openidconnect", "pretty_assertions", "sealed_test", "serde", "serde_json", - "sqlx 0.7.2", + "sqlx 0.7.3", "tokio", "tower", "tower-http", @@ -2253,6 +2357,17 @@ dependencies = [ "zitadel", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.4.1", + "cfg-if 1.0.0", + "libc", +] + [[package]] name = "nom" version = "7.1.3" @@ -2268,8 +2383,8 @@ name = "noop" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.6.16", - "clap 4.4.8", + "axum 0.7.1", + "clap 4.4.10", "nefarious-login", "tokio", "tracing-subscriber", @@ -2363,7 +2478,7 @@ dependencies = [ "base64 0.13.1", "chrono", "getrandom", - "http", + "http 0.2.11", "rand", "reqwest", "serde", @@ -2406,7 +2521,7 @@ dependencies = [ "dyn-clone", "ed25519-dalek", "hmac 0.12.1", - "http", + "http 0.2.11", "itertools 0.10.5", "log", "oauth2", @@ -2429,9 +2544,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.59" +version = "0.10.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" +checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800" dependencies = [ "bitflags 2.4.1", "cfg-if 1.0.0", @@ -2461,9 +2576,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.95" +version = "0.9.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" +checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" dependencies = [ "cc", "libc", @@ -2561,7 +2676,7 @@ dependencies = [ "libc", "redox_syscall 0.4.1", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -2591,9 +2706,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" @@ -2684,21 +2799,21 @@ dependencies = [ "libc", "log", "pin-project-lite", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "polling" -version = "3.3.0" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" dependencies = [ "cfg-if 1.0.0", "concurrent-queue", "pin-project-lite", "rustix 0.38.25", "tracing", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2746,9 +2861,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -2882,8 +2997,8 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", + "h2 0.3.22", + "http 0.2.11", "http-body 0.4.5", "hyper 0.14.27", "hyper-rustls", @@ -2932,14 +3047,14 @@ dependencies = [ "libc", "spin 0.9.8", "untrusted", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "rsa" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a3211b01eea83d80687da9eef70e39d65144a3894866a5153a2723e425a157f" +checksum = "af6c4b23d99685a1408194da11270ef8e9809aff951cc70ec9b17350b087e474" dependencies = [ "const-oid", "digest 0.10.7", @@ -2981,7 +3096,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys 0.3.8", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2994,7 +3109,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.11", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3058,7 +3173,7 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3361,7 +3476,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3423,12 +3538,12 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e50c216e3624ec8e7ecd14c6a6a6370aad6ee5d8cfc3ab30b5162eeeef2ed33" +checksum = "dba03c279da73694ef99763320dea58b51095dfe87d001b1d4b5fe78ba8763cf" dependencies = [ - "sqlx-core 0.7.2", - "sqlx-macros 0.7.2", + "sqlx-core 0.7.3", + "sqlx-macros 0.7.3", "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", @@ -3485,9 +3600,9 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d6753e460c998bbd4cd8c6f0ed9a64346fcca0723d6e75e52fdc351c5d2169d" +checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" dependencies = [ "ahash 0.8.6", "atoi 2.0.0", @@ -3545,23 +3660,24 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a793bb3ba331ec8359c1853bd39eed32cdd7baaf22c35ccf5c92a7e8d1189ec" +checksum = "89961c00dc4d7dffb7aee214964b065072bff69e36ddb9e2c107541f75e4f2a5" dependencies = [ "proc-macro2", "quote", - "sqlx-core 0.7.2", + "sqlx-core 0.7.3", "sqlx-macros-core", "syn 1.0.109", ] [[package]] name = "sqlx-macros-core" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4ee1e104e00dedb6aa5ffdd1343107b0a4702e862a84320ee7cc74782d96fc" +checksum = "d0bd4519486723648186a08785143599760f7cc81c52334a55d6a83ea1e20841" dependencies = [ + "atomic-write-file", "dotenvy", "either", "heck", @@ -3572,7 +3688,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "sqlx-core 0.7.2", + "sqlx-core 0.7.3", "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", @@ -3584,9 +3700,9 @@ dependencies = [ [[package]] name = "sqlx-mysql" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" +checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4" dependencies = [ "atoi 2.0.0", "base64 0.21.5", @@ -3617,7 +3733,7 @@ dependencies = [ "sha1", "sha2 0.10.8", "smallvec", - "sqlx-core 0.7.2", + "sqlx-core 0.7.3", "stringprep", "thiserror", "tracing", @@ -3626,9 +3742,9 @@ dependencies = [ [[package]] name = "sqlx-postgres" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" +checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24" dependencies = [ "atoi 2.0.0", "base64 0.21.5", @@ -3656,7 +3772,7 @@ dependencies = [ "sha1", "sha2 0.10.8", "smallvec", - "sqlx-core 0.7.2", + "sqlx-core 0.7.3", "stringprep", "thiserror", "tracing", @@ -3676,9 +3792,9 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59dc83cf45d89c555a577694534fcd1b55c545a816c816ce51f20bbe56a4f3f" +checksum = "210976b7d948c7ba9fced8ca835b11cbb2d677c59c79de41ac0d397e14547490" dependencies = [ "atoi 2.0.0", "flume", @@ -3691,9 +3807,10 @@ dependencies = [ "log", "percent-encoding", "serde", - "sqlx-core 0.7.2", + "sqlx-core 0.7.3", "tracing", "url", + "urlencoding", ] [[package]] @@ -3778,7 +3895,7 @@ dependencies = [ "fastrand 2.0.1", "redox_syscall 0.4.1", "rustix 0.38.25", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3871,7 +3988,7 @@ dependencies = [ "signal-hook-registry", "socket2 0.5.5", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3946,7 +4063,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", + "http 0.2.11", "http-body 0.4.5", "http-range-header", "pin-project-lite", @@ -3955,21 +4072,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-hyper-http-body-compat" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ea3e622710ee44a8255baa6fcb2a34d67450e2ffb48e5e58d5a7bd6ff55a21" -dependencies = [ - "http", - "http-body 0.4.5", - "http-body 1.0.0-rc.2", - "hyper 1.0.0-rc.4", - "pin-project-lite", - "tower", - "tower-service", -] - [[package]] name = "tower-layer" version = "0.3.2" @@ -4107,9 +4209,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -4117,6 +4219,12 @@ dependencies = [ "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8parse" version = "0.2.1" @@ -4188,9 +4296,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -4198,9 +4306,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", @@ -4213,9 +4321,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -4225,9 +4333,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4235,9 +4343,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", @@ -4248,9 +4356,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "web-sys" @@ -4264,9 +4372,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] name = "whoami" @@ -4306,7 +4414,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -4315,7 +4423,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -4324,13 +4441,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -4339,42 +4471,84 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winreg" version = "0.50.0" @@ -4382,7 +4556,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if 1.0.0", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f5c2deb..394fa47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,10 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } clap = { version = "4", features = ["derive", "env"] } async-trait = { version = "0.1", features = [] } -axum = { git = "https://github.com/tokio-rs/axum", branch = "main", features = [ +axum = { version = "0.7.1", features = [ "macros", ] } -axum-extra = { git = "https://github.com/tokio-rs/axum", branch = "main", features = [ +axum-extra = { version = "0.9.0", features = [ "cookie", "cookie-private", "typed-header",