diff --git a/src/api/ruma_wrapper/auth.rs b/src/api/ruma_wrapper/auth.rs index 282248c1..43737d20 100644 --- a/src/api/ruma_wrapper/auth.rs +++ b/src/api/ruma_wrapper/auth.rs @@ -4,7 +4,7 @@ use axum::RequestPartsExt; use axum_extra::{headers::Authorization, typed_header::TypedHeaderRejectionReason, TypedHeader}; use http::uri::PathAndQuery; use ruma::{ - api::{client::error::ErrorKind, AuthScheme, IncomingRequest}, + api::{client::error::ErrorKind, AuthScheme}, CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId, UserId, }; use tracing::warn; @@ -26,11 +26,7 @@ pub(super) struct Auth { pub(super) appservice_info: Option, } -pub(super) async fn auth(request: &mut Request) -> Result -where - T: IncomingRequest, -{ - let metadata = T::METADATA; +pub(super) async fn auth(request: &mut Request, metadata: &ruma::api::Metadata) -> Result { let token = match &request.auth { Some(TypedHeader(Authorization(bearer))) => Some(bearer.token()), None => request.query.access_token.as_deref(), diff --git a/src/api/ruma_wrapper/request.rs b/src/api/ruma_wrapper/request.rs index 4a60bbd2..b74fbd3e 100644 --- a/src/api/ruma_wrapper/request.rs +++ b/src/api/ruma_wrapper/request.rs @@ -45,8 +45,9 @@ where type Rejection = Error; async fn from_request(request: hyper::Request, _state: &S) -> Result { + let meta = T::METADATA; let mut request: Request = extract(request).await?; - let auth: Auth = auth::auth::(&mut request).await?; + let auth: Auth = auth::auth(&mut request, &meta).await?; let body = make_body::(&mut request, &auth)?; Ok(Ruma { body,