You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-20 12:02:22 +03:00
Finish moving the site config
This commit is contained in:
@@ -16,7 +16,9 @@ use axum::{extract::State, response::IntoResponse, Json, TypedHeader};
|
||||
use chrono::Duration;
|
||||
use hyper::StatusCode;
|
||||
use mas_axum_utils::sentry::SentryEventID;
|
||||
use mas_data_model::{CompatSession, CompatSsoLoginState, Device, TokenType, User, UserAgent};
|
||||
use mas_data_model::{
|
||||
CompatSession, CompatSsoLoginState, Device, SiteConfig, TokenType, User, UserAgent,
|
||||
};
|
||||
use mas_matrix::BoxHomeserverConnection;
|
||||
use mas_storage::{
|
||||
compat::{
|
||||
@@ -34,10 +36,7 @@ use thiserror::Error;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use super::MatrixError;
|
||||
use crate::{
|
||||
impl_from_error_for_route, passwords::PasswordManager, site_config::SiteConfig,
|
||||
BoundActivityTracker,
|
||||
};
|
||||
use crate::{impl_from_error_for_route, passwords::PasswordManager, BoundActivityTracker};
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -16,7 +16,7 @@ use axum::{extract::State, response::IntoResponse, Json};
|
||||
use chrono::Duration;
|
||||
use hyper::StatusCode;
|
||||
use mas_axum_utils::sentry::SentryEventID;
|
||||
use mas_data_model::{TokenFormatError, TokenType};
|
||||
use mas_data_model::{SiteConfig, TokenFormatError, TokenType};
|
||||
use mas_storage::{
|
||||
compat::{CompatAccessTokenRepository, CompatRefreshTokenRepository, CompatSessionRepository},
|
||||
BoxClock, BoxRepository, BoxRng, Clock,
|
||||
@@ -26,7 +26,7 @@ use serde_with::{serde_as, DurationMilliSeconds};
|
||||
use thiserror::Error;
|
||||
|
||||
use super::MatrixError;
|
||||
use crate::{impl_from_error_for_route, site_config::SiteConfig, BoundActivityTracker};
|
||||
use crate::{impl_from_error_for_route, BoundActivityTracker};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct RequestBody {
|
||||
|
||||
@@ -41,6 +41,7 @@ use hyper::{
|
||||
StatusCode, Version,
|
||||
};
|
||||
use mas_axum_utils::{cookies::CookieJar, FancyError};
|
||||
use mas_data_model::SiteConfig;
|
||||
use mas_http::CorsLayerExt;
|
||||
use mas_keystore::{Encrypter, Keystore};
|
||||
use mas_matrix::BoxHomeserverConnection;
|
||||
@@ -63,7 +64,6 @@ mod views;
|
||||
|
||||
mod activity_tracker;
|
||||
mod preferred_language;
|
||||
mod site_config;
|
||||
#[cfg(test)]
|
||||
mod test_utils;
|
||||
|
||||
@@ -91,7 +91,6 @@ pub use self::{
|
||||
activity_tracker::{ActivityTracker, Bound as BoundActivityTracker},
|
||||
graphql::schema as graphql_schema,
|
||||
preferred_language::PreferredLanguage,
|
||||
site_config::{SiteConfig, SiteConfigExt},
|
||||
upstream_oauth2::cache::MetadataCache,
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ use mas_axum_utils::{
|
||||
sentry::SentryEventID,
|
||||
};
|
||||
use mas_data_model::{
|
||||
AuthorizationGrantStage, Client, Device, DeviceCodeGrantState, TokenType, UserAgent,
|
||||
AuthorizationGrantStage, Client, Device, DeviceCodeGrantState, SiteConfig, TokenType, UserAgent,
|
||||
};
|
||||
use mas_keystore::{Encrypter, Keystore};
|
||||
use mas_oidc_client::types::scope::ScopeToken;
|
||||
@@ -54,7 +54,7 @@ use ulid::Ulid;
|
||||
use url::Url;
|
||||
|
||||
use super::{generate_id_token, generate_token_pair};
|
||||
use crate::{impl_from_error_for_route, site_config::SiteConfig, BoundActivityTracker};
|
||||
use crate::{impl_from_error_for_route, BoundActivityTracker};
|
||||
|
||||
#[serde_as]
|
||||
#[skip_serializing_none]
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
// Copyright 2023, 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub use mas_data_model::SiteConfig;
|
||||
use mas_templates::{SiteBranding, SiteFeatures};
|
||||
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
pub trait SiteConfigExt {
|
||||
fn templates_branding(&self) -> SiteBranding;
|
||||
fn templates_features(&self) -> SiteFeatures;
|
||||
}
|
||||
|
||||
impl SiteConfigExt for SiteConfig {
|
||||
fn templates_branding(&self) -> SiteBranding {
|
||||
let mut branding = SiteBranding::new(self.server_name.clone());
|
||||
|
||||
if let Some(policy_uri) = &self.policy_uri {
|
||||
branding = branding.with_policy_uri(policy_uri.as_str());
|
||||
}
|
||||
|
||||
if let Some(tos_uri) = &self.tos_uri {
|
||||
branding = branding.with_tos_uri(tos_uri.as_str());
|
||||
}
|
||||
|
||||
if let Some(imprint) = &self.imprint {
|
||||
branding = branding.with_imprint(imprint.as_str());
|
||||
}
|
||||
|
||||
branding
|
||||
}
|
||||
|
||||
fn templates_features(&self) -> SiteFeatures {
|
||||
SiteFeatures {
|
||||
password_registration: self.password_registration_enabled,
|
||||
password_login: self.password_login_enabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ use mas_axum_utils::{
|
||||
http_client_factory::HttpClientFactory,
|
||||
ErrorWrapper,
|
||||
};
|
||||
use mas_data_model::SiteConfig;
|
||||
use mas_i18n::Translator;
|
||||
use mas_keystore::{Encrypter, JsonWebKey, JsonWebKeySet, Keystore, PrivateKey};
|
||||
use mas_matrix::{BoxHomeserverConnection, HomeserverConnection, MockHomeserverConnection};
|
||||
@@ -44,7 +45,7 @@ use mas_policy::{InstantiateError, Policy, PolicyFactory};
|
||||
use mas_router::{SimpleRoute, UrlBuilder};
|
||||
use mas_storage::{clock::MockClock, BoxClock, BoxRepository, BoxRng, Repository};
|
||||
use mas_storage_pg::{DatabaseError, PgRepository};
|
||||
use mas_templates::Templates;
|
||||
use mas_templates::{SiteConfigExt, Templates};
|
||||
use rand::SeedableRng;
|
||||
use rand_chacha::ChaChaRng;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
@@ -54,9 +55,8 @@ use url::Url;
|
||||
|
||||
use crate::{
|
||||
passwords::{Hasher, PasswordManager},
|
||||
site_config::SiteConfig,
|
||||
upstream_oauth2::cache::MetadataCache,
|
||||
ActivityTracker, BoundActivityTracker, SiteConfigExt,
|
||||
ActivityTracker, BoundActivityTracker,
|
||||
};
|
||||
|
||||
// This might fail if it's not the first time it's being called, which is fine,
|
||||
|
||||
Reference in New Issue
Block a user