mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-30 22:43:10 +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 axum_extra::{headers::Authorization, typed_header::TypedHeaderRejectionReason, TypedHeader};
|
||||||
use http::uri::PathAndQuery;
|
use http::uri::PathAndQuery;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{client::error::ErrorKind, AuthScheme, IncomingRequest},
|
api::{client::error::ErrorKind, AuthScheme},
|
||||||
CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId, UserId,
|
CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId, UserId,
|
||||||
};
|
};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
@ -26,11 +26,7 @@ pub(super) struct Auth {
|
||||||
pub(super) appservice_info: Option<RegistrationInfo>,
|
pub(super) appservice_info: Option<RegistrationInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn auth<T>(request: &mut Request) -> Result<Auth>
|
pub(super) async fn auth(request: &mut Request, metadata: &ruma::api::Metadata) -> Result<Auth> {
|
||||||
where
|
|
||||||
T: IncomingRequest,
|
|
||||||
{
|
|
||||||
let metadata = T::METADATA;
|
|
||||||
let token = match &request.auth {
|
let token = match &request.auth {
|
||||||
Some(TypedHeader(Authorization(bearer))) => Some(bearer.token()),
|
Some(TypedHeader(Authorization(bearer))) => Some(bearer.token()),
|
||||||
None => request.query.access_token.as_deref(),
|
None => request.query.access_token.as_deref(),
|
||||||
|
|
|
@ -45,8 +45,9 @@ where
|
||||||
type Rejection = Error;
|
type Rejection = Error;
|
||||||
|
|
||||||
async fn from_request(request: hyper::Request<axum::body::Body>, _state: &S) -> Result<Self, Self::Rejection> {
|
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 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)?;
|
let body = make_body::<T>(&mut request, &auth)?;
|
||||||
Ok(Ruma {
|
Ok(Ruma {
|
||||||
body,
|
body,
|
||||||
|
|
Loading…
Reference in a new issue