1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-20 12:02:22 +03:00

Simplify the HTTP client building

Also supports loading the WebPKI roots instead of the native ones for
TLS
This commit is contained in:
Quentin Gliech
2022-09-15 16:00:33 +02:00
parent a663deb7e1
commit 7b819ffa8b
10 changed files with 216 additions and 148 deletions

View File

@@ -39,7 +39,7 @@ use serde::{de::DeserializeOwned, Deserialize};
use serde_json::Value;
use sqlx::PgExecutor;
use thiserror::Error;
use tower::ServiceExt;
use tower::{Service, ServiceExt};
static JWT_BEARER_CLIENT_ASSERTION: &str = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
@@ -177,12 +177,12 @@ async fn fetch_jwks(jwks: &JwksOrJwksUri) -> Result<PublicJsonWebKeySet, BoxErro
.body(http_body::Empty::new())
.unwrap();
let client = mas_http::client("fetch-jwks")
let mut client = mas_http::client("fetch-jwks")
.await?
.response_body_to_bytes()
.json_response::<PublicJsonWebKeySet>()
.map_err(Box::new);
.json_response::<PublicJsonWebKeySet>();
let response = client.oneshot(request).await?;
let response = client.ready().await?.call(request).await?;
Ok(response.into_body())
}