diff --git a/Cargo.lock b/Cargo.lock index 65f9227..b8b0dc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -183,9 +183,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" [[package]] name = "cfg-if" @@ -272,12 +272,11 @@ dependencies = [ [[package]] name = "dmds" -version = "0.2.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "378c5c867d4f71ce0ba34d27982d9783ee405fd77e7c58317e71e6dcc830d6a5" +checksum = "80365beb994e31522b7d67b389986618a89570feb004192c2d4ba5ef334e11c7" dependencies = [ "async-lock", - "async-trait", "bytes", "dashmap", "futures-lite", @@ -286,11 +285,10 @@ dependencies = [ [[package]] name = "dmds-tokio-fs" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8ed854a5d73c95b951344d433f0ba3f04f0c41a550e44cf401e815c68cca8f" +checksum = "b40a4829bfe78f05567e3a8711f221aa80faefd7cf88f5e136ffd3077fd79259" dependencies = [ - "async-trait", "bytes", "dashmap", "dmds", @@ -578,9 +576,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f24ce812868d86d19daa79bf3bf9175bc44ea323391147a5e3abde2a283871b" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" dependencies = [ "bytes", "futures-channel", @@ -878,9 +876,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -971,9 +969,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustls" -version = "0.23.4" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4d6d8ad9f2492485e13453acbb291dd08f64441b6609c491f1c2cd2c6b4fe1" +checksum = "afabcee0551bd1aa3e18e5adbf2c0544722014b899adb31bd186ec638d3da97e" dependencies = [ "log", "once_cell", @@ -1002,9 +1000,9 @@ checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" [[package]] name = "rustls-webpki" -version = "0.102.2" +version = "0.102.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" dependencies = [ "ring", "rustls-pki-types", @@ -1031,18 +1029,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", @@ -1151,7 +1149,6 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" name = "sms4-backend" version = "0.1.0" dependencies = [ - "async-trait", "axum", "axum-macros", "bincode", @@ -1214,9 +1211,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.59" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -1237,18 +1234,18 @@ checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 380e9d3..6b2d09c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,8 @@ edition = "2021" axum = "0.7" axum-macros = "0.4" libaccount = { version = "0.1", git = "https://github.com/subitlab-buf/libaccount.git" } -dmds = "0.2" -dmds-tokio-fs = "0.2" +dmds = "0.4" +dmds-tokio-fs = "0.3" tokio = { version = "1.35", features = [ "rt", "macros", @@ -39,7 +39,6 @@ thiserror = "1.0" rand = "0.8" siphasher = "1.0" highway = "1.1" -async-trait = "0.1" http-body-util = "0.1" [dev-dependencies] diff --git a/src/main.rs b/src/main.rs index d2c93de..740b9ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,22 +171,34 @@ impl Auth { } } -#[async_trait::async_trait] impl axum::extract::FromRequestParts> for Auth { type Rejection = Error; - async fn from_request_parts( - parts: &mut axum::http::request::Parts, - _state: &Global, - ) -> Result { - let raw = parts.headers.remove(Self::KEY).ok_or(Error::NotLoggedIn)?; - let (account, token) = raw - .to_str()? - .split_once(':') - .ok_or(Error::InvalidAuthHeader)?; - Ok(Self { - account: account.parse().map_err(|_| Error::InvalidAuthHeader)?, - token: token.to_owned(), + fn from_request_parts<'life0, 'life1, 'async_trait>( + parts: &'life0 mut axum::http::request::Parts, + _state: &'life1 Global, + ) -> core::pin::Pin< + Box< + dyn core::future::Future> + + core::marker::Send + + 'async_trait, + >, + > + where + 'life0: 'async_trait, + 'life1: 'async_trait, + Self: 'async_trait, + { + Box::pin(async { + let raw = parts.headers.remove(Self::KEY).ok_or(Error::NotLoggedIn)?; + let (account, token) = raw + .to_str()? + .split_once(':') + .ok_or(Error::InvalidAuthHeader)?; + Ok(Self { + account: account.parse().map_err(|_| Error::InvalidAuthHeader)?, + token: token.to_owned(), + }) }) } }