mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-27 20:45:30 +00:00
elminate generic argument in ruma_wrapper::auth
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
0e3d192ad2
commit
73718a1208
|
@ -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<RegistrationInfo>,
|
||||
}
|
||||
|
||||
pub(super) async fn auth<T>(request: &mut Request) -> Result<Auth>
|
||||
where
|
||||
T: IncomingRequest,
|
||||
{
|
||||
let metadata = T::METADATA;
|
||||
pub(super) async fn auth(request: &mut Request, metadata: &ruma::api::Metadata) -> Result<Auth> {
|
||||
let token = match &request.auth {
|
||||
Some(TypedHeader(Authorization(bearer))) => Some(bearer.token()),
|
||||
None => request.query.access_token.as_deref(),
|
||||
|
|
|
@ -45,8 +45,9 @@ where
|
|||
type Rejection = Error;
|
||||
|
||||
async fn from_request(request: hyper::Request<axum::body::Body>, _state: &S) -> Result<Self, Self::Rejection> {
|
||||
let meta = T::METADATA;
|
||||
let mut request: Request = extract(request).await?;
|
||||
let auth: Auth = auth::auth::<T>(&mut request).await?;
|
||||
let auth: Auth = auth::auth(&mut request, &meta).await?;
|
||||
let body = make_body::<T>(&mut request, &auth)?;
|
||||
Ok(Ruma {
|
||||
body,
|
||||
|
|
Loading…
Reference in a new issue