mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-07-02 16:38:36 +00:00
feat: base support
This commit is contained in:
parent
139588b64c
commit
67c23d6dd4
9 changed files with 148 additions and 178 deletions
|
@ -11,6 +11,7 @@ use crate::{
|
|||
utils, Error, Result,
|
||||
};
|
||||
use futures_util::future::{self};
|
||||
use http::HeaderValue;
|
||||
use mas_oidc_client::{
|
||||
http_service::HttpService,
|
||||
requests::{authorization_code::AuthorizationValidationData, discovery},
|
||||
|
@ -20,6 +21,7 @@ use ruma::{api::client::session::get_login_types::v3::IdentityProvider, OwnedUse
|
|||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::OnceCell;
|
||||
use tower::BoxError;
|
||||
use tower_http::{set_header::SetRequestHeaderLayer, ServiceBuilderExt};
|
||||
use tracing::error;
|
||||
use url::Url;
|
||||
|
||||
|
@ -43,14 +45,17 @@ impl Service {
|
|||
pub fn build(db: &'static dyn Data) -> Result<Arc<Self>> {
|
||||
let client = tower::ServiceBuilder::new()
|
||||
.map_err(BoxError::from)
|
||||
.layer(tower_http::timeout::TimeoutLayer::new(
|
||||
std::time::Duration::from_secs(10),
|
||||
))
|
||||
.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),
|
||||
// ))
|
||||
.layer(SetRequestHeaderLayer::overriding(
|
||||
http::header::USER_AGENT,
|
||||
HeaderValue::from_static("conduit/0.9-alpha"),
|
||||
))
|
||||
.concurrency_limit(10)
|
||||
.follow_redirects()
|
||||
.service(mas_http::make_untraced_client());
|
||||
|
||||
Ok(Arc::new(Self {
|
||||
|
@ -157,8 +162,8 @@ impl LoginToken {
|
|||
.expect("time overflow"),
|
||||
}
|
||||
}
|
||||
pub fn audience(&self) -> &UserId {
|
||||
&self.aud
|
||||
pub fn audience(self) -> OwnedUserId {
|
||||
self.aud
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue