1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-07-02 16:38:36 +00:00
This commit is contained in:
avdb13 2024-07-15 06:08:25 +02:00
parent 5af171e7ee
commit 139588b64c
4 changed files with 131 additions and 21 deletions

View file

@ -12,13 +12,14 @@ use crate::{
};
use futures_util::future::{self};
use mas_oidc_client::{
http_service::{hyper, HttpService},
http_service::HttpService,
requests::{authorization_code::AuthorizationValidationData, discovery},
types::oidc::VerifiedProviderMetadata,
};
use ruma::{api::client::session::get_login_types::v3::IdentityProvider, OwnedUserId, UserId};
use serde::{Deserialize, Serialize};
use tokio::sync::OnceCell;
use tower::BoxError;
use tracing::error;
use url::Url;
@ -40,9 +41,21 @@ pub struct Service {
impl Service {
pub fn build(db: &'static dyn Data) -> Result<Arc<Self>> {
let client = tower::ServiceBuilder::new()
.map_err(BoxError::from)
.layer(mas_http::BytesToBodyRequestLayer)
.layer(mas_http::BodyToBytesResponseLayer)
// .override_request_header(http::header::USER_AGENT, "conduit".to_owned())
// .concurrency_limit(10)
// .follow_redirects()
// .layer(tower_http::timeout::TimeoutLayer::new(
// std::time::Duration::from_secs(10),
// ))
.service(mas_http::make_untraced_client());
Ok(Arc::new(Self {
db,
service: HttpService::new(hyper::hyper_service()),
service: HttpService::new(client),
providers: OnceCell::new(),
}))
}
@ -159,7 +172,11 @@ pub struct ValidationData {
impl ValidationData {
pub fn new(provider: String, redirect_url: String, inner: AuthorizationValidationData) -> Self {
Self { provider, redirect_url, inner }
Self {
provider,
redirect_url,
inner,
}
}
}