You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-09 04:22:45 +03:00
Move tower-http dep to the workspace and adapt mas-axum-utils
We removed here the Timeout layer on the HTTP client service, because it required the body to be Default, which isn't the case anymore. Not sure what to do about it.
This commit is contained in:
@@ -16,14 +16,14 @@ use std::collections::HashMap;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use axum::{
|
||||
body::HttpBody,
|
||||
extract::{
|
||||
rejection::{FailedToDeserializeForm, FormRejection, TypedHeaderRejectionReason},
|
||||
Form, FromRequest, FromRequestParts, TypedHeader,
|
||||
rejection::{FailedToDeserializeForm, FormRejection},
|
||||
Form, FromRequest, FromRequestParts,
|
||||
},
|
||||
response::IntoResponse,
|
||||
BoxError, Json,
|
||||
};
|
||||
use axum_extra::typed_header::{TypedHeader, TypedHeaderRejectionReason};
|
||||
use headers::{authorization::Basic, Authorization};
|
||||
use http::{Request, StatusCode};
|
||||
use mas_data_model::{Client, JwksOrJwksUri};
|
||||
@@ -337,18 +337,18 @@ impl IntoResponse for ClientAuthorizationError {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S, B, F> FromRequest<S, B> for ClientAuthorization<F>
|
||||
impl<S, F> FromRequest<S> for ClientAuthorization<F>
|
||||
where
|
||||
F: DeserializeOwned,
|
||||
B: HttpBody + Send + 'static,
|
||||
B::Data: Send,
|
||||
B::Error: Into<BoxError>,
|
||||
S: Send + Sync,
|
||||
{
|
||||
type Rejection = ClientAuthorizationError;
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
async fn from_request(req: Request<B>, state: &S) -> Result<Self, Self::Rejection> {
|
||||
async fn from_request(
|
||||
req: Request<axum::body::Body>,
|
||||
state: &S,
|
||||
) -> Result<Self, Self::Rejection> {
|
||||
// Split the request into parts so we can extract some headers
|
||||
let (mut parts, body) = req.into_parts();
|
||||
|
||||
|
@@ -15,8 +15,9 @@
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
Extension, TypedHeader,
|
||||
Extension,
|
||||
};
|
||||
use axum_extra::typed_header::TypedHeader;
|
||||
use headers::ContentType;
|
||||
use mas_templates::ErrorContext;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
// Copyright 2022-2024 The Matrix.org Foundation C.I.C.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -12,7 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use axum::body::Full;
|
||||
use http_body_util::Full;
|
||||
use hyper_util::rt::TokioExecutor;
|
||||
use mas_http::{
|
||||
make_traced_connector, BodyToBytesResponseLayer, Client, ClientLayer, ClientService,
|
||||
HttpService, TracedClient, TracedConnector,
|
||||
@@ -50,7 +51,7 @@ impl HttpClientFactory {
|
||||
B: axum::body::HttpBody + Send,
|
||||
B::Data: Send,
|
||||
{
|
||||
let client = Client::builder().build(self.traced_connector.clone());
|
||||
let client = Client::builder(TokioExecutor::new()).build(self.traced_connector.clone());
|
||||
self.client_layer
|
||||
.clone()
|
||||
.with_category(category)
|
||||
|
@@ -12,10 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use axum::{
|
||||
response::{IntoResponse, Response},
|
||||
TypedHeader,
|
||||
};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum_extra::typed_header::TypedHeader;
|
||||
use headers::ContentType;
|
||||
use mas_jose::jwt::Jwt;
|
||||
use mime::Mime;
|
||||
|
@@ -16,14 +16,13 @@ use std::{collections::HashMap, error::Error};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use axum::{
|
||||
body::HttpBody,
|
||||
extract::{
|
||||
rejection::{FailedToDeserializeForm, FormRejection, TypedHeaderRejectionReason},
|
||||
Form, FromRequest, FromRequestParts, TypedHeader,
|
||||
rejection::{FailedToDeserializeForm, FormRejection},
|
||||
Form, FromRequest, FromRequestParts,
|
||||
},
|
||||
response::{IntoResponse, Response},
|
||||
BoxError,
|
||||
};
|
||||
use axum_extra::typed_header::{TypedHeader, TypedHeaderRejectionReason};
|
||||
use headers::{authorization::Bearer, Authorization, Header, HeaderMapExt, HeaderName};
|
||||
use http::{header::WWW_AUTHENTICATE, HeaderMap, HeaderValue, Request, StatusCode};
|
||||
use mas_data_model::Session;
|
||||
@@ -289,17 +288,17 @@ where
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S, B, F> FromRequest<S, B> for UserAuthorization<F>
|
||||
impl<S, F> FromRequest<S> for UserAuthorization<F>
|
||||
where
|
||||
F: DeserializeOwned,
|
||||
B: HttpBody + Send + 'static,
|
||||
B::Data: Send,
|
||||
B::Error: Into<BoxError>,
|
||||
S: Send + Sync,
|
||||
{
|
||||
type Rejection = UserAuthorizationError;
|
||||
|
||||
async fn from_request(req: Request<B>, state: &S) -> Result<Self, Self::Rejection> {
|
||||
async fn from_request(
|
||||
req: Request<axum::body::Body>,
|
||||
state: &S,
|
||||
) -> Result<Self, Self::Rejection> {
|
||||
let (mut parts, body) = req.into_parts();
|
||||
let header =
|
||||
TypedHeader::<Authorization<Bearer>>::from_request_parts(&mut parts, state).await;
|
||||
|
Reference in New Issue
Block a user