diff --git a/Cargo.lock b/Cargo.lock index a3dd7de4..3f056b2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,16 +136,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.4.5", "bytes", "futures-util", "http", "http-body", "http-body-util", + "itoa", + "matchit 0.7.3", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" +dependencies = [ + "axum-core 0.5.2", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", "hyper", "hyper-util", "itoa", - "matchit", + "matchit 0.8.4", "memchr", "mime", "percent-encoding", @@ -181,27 +208,45 @@ dependencies = [ "sync_wrapper", "tower-layer", "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", "tracing", ] [[package]] name = "axum-extra" -version = "0.9.6" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c794b30c904f0a1c2fb7740f7df7f7972dfaa14ef6f57cb6178dc63e5dca2f04" +checksum = "45bf463831f5131b7d3c756525b305d40f1185b688565648a92e1392ca35713d" dependencies = [ - "axum", - "axum-core", + "axum 0.8.4", + "axum-core 0.5.2", "bytes", - "fastrand", "futures-util", "headers", "http", "http-body", "http-body-util", "mime", - "multer", "pin-project-lite", + "rustversion", "serde", "tower 0.5.2", "tower-layer", @@ -660,15 +705,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" -[[package]] -name = "encoding_rs" -version = "0.8.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" -dependencies = [ - "cfg-if", -] - [[package]] name = "enum-as-inner" version = "0.6.1" @@ -916,7 +952,7 @@ dependencies = [ "argon2", "assert_cmd", "async-trait", - "axum", + "axum 0.8.4", "axum-extra", "axum-server", "base64 0.22.1", @@ -1659,6 +1695,12 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "memchr" version = "2.7.4" @@ -1698,23 +1740,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "multer" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" -dependencies = [ - "bytes", - "encoding_rs", - "futures-util", - "http", - "httparse", - "memchr", - "mime", - "spin", - "version_check", -] - [[package]] name = "nix" version = "0.29.0" @@ -3093,12 +3118,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "spki" version = "0.7.3" @@ -3434,7 +3453,7 @@ checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", - "axum", + "axum 0.7.9", "base64 0.22.1", "bytes", "h2", diff --git a/Cargo.toml b/Cargo.toml index 6c61f19e..ea70b7b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,8 +90,8 @@ workspace = true [dependencies] argon2 = "0.5.3" async-trait = "0.1.88" -axum = { version = "0.7.9", default-features = false, features = ["form", "http1", "http2", "json", "matched-path", "tokio", "tracing"] } -axum-extra = { version = "0.9.5", features = ["typed-header"] } +axum = { version = "0.8.4", default-features = false, features = ["form", "http1", "http2", "json", "matched-path", "tokio", "tracing"] } +axum-extra = { version = "0.10.1", features = ["typed-header"] } axum-server = { git = "https://gitlab.computer.surgery/matrix/thirdparty/axum-server.git", rev = "v0.7.2+grapevine-1", version = "0.7.2", features = ["tls-rustls-no-provider"] } base64 = "0.22.1" bytes = "1.10.1" diff --git a/src/api/ruma_wrapper/axum.rs b/src/api/ruma_wrapper/axum.rs index 712386d9..55790445 100644 --- a/src/api/ruma_wrapper/axum.rs +++ b/src/api/ruma_wrapper/axum.rs @@ -1,7 +1,6 @@ use std::{collections::BTreeMap, iter::FromIterator, str}; use axum::{ - async_trait, body::Body, extract::{FromRequest, Path}, response::{IntoResponse, Response}, @@ -398,10 +397,10 @@ async fn ar_from_request_inner( }) } -#[async_trait] impl FromRequest for Ar where T: IncomingRequest, + S: Sync, { type Rejection = Error; diff --git a/src/cli/serve.rs b/src/cli/serve.rs index e1bc79c7..7a528748 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -209,13 +209,14 @@ struct ServerSpawner<'cfg, M> { impl<'cfg, M> ServerSpawner<'cfg, M> where - M: Layer + Clone + Send + 'static, + M: Layer + Clone + Send + Sync + 'static, M::Service: Service< axum::extract::Request, Response = axum::response::Response, Error = Infallible, > + Clone + Send + + Sync + 'static, >::Future: Send + 'static, { @@ -929,14 +930,13 @@ pub(crate) trait RumaHandler { macro_rules! impl_ruma_handler { ( $($ty:ident),* $(,)? ) => { - #[axum::async_trait] #[allow(non_snake_case)] impl RumaHandler<($($ty,)* Ar,)> for F where Req: IncomingRequest + Send + 'static, Resp: IntoResponse, - F: FnOnce($($ty,)* Ar) -> Fut + Clone + Send + 'static, + F: FnOnce($($ty,)* Ar) -> Fut + Clone + Send + Sync + 'static, Fut: Future> + Send, E: IntoResponse, diff --git a/src/utils/error.rs b/src/utils/error.rs index 0b5420b3..48ae5243 100644 --- a/src/utils/error.rs +++ b/src/utils/error.rs @@ -1,5 +1,6 @@ use std::convert::Infallible; +use axum_extra::typed_header::TypedHeaderRejection; use http::StatusCode; use ruma::{ api::client::{ @@ -51,6 +52,11 @@ pub(crate) enum Error { #[from] source: regex::Error, }, + #[error("Invalid header value: {source}")] + InvalidHeaderValue { + #[from] + source: TypedHeaderRejection, + }, #[error("{0}")] Federation(OwnedServerName, RumaError), #[error("Could not do this io: {source}")]