You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-07 17:03:01 +03:00
Add instance privacy policy, TOS and imprint, and loads of design cleanups
This commit is contained in:
@@ -93,7 +93,13 @@ impl Options {
|
||||
);
|
||||
|
||||
// Load and compile the templates
|
||||
let templates = templates_from_config(&config.templates, &url_builder).await?;
|
||||
let templates = templates_from_config(
|
||||
&config.templates,
|
||||
&config.branding,
|
||||
&url_builder,
|
||||
&config.matrix.homeserver,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let http_client_factory = HttpClientFactory::new().await?;
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use clap::Parser;
|
||||
use mas_config::TemplatesConfig;
|
||||
use mas_config::{BrandingConfig, MatrixConfig, TemplatesConfig};
|
||||
use mas_storage::{Clock, SystemClock};
|
||||
use rand::SeedableRng;
|
||||
use tracing::info_span;
|
||||
@@ -39,13 +39,22 @@ impl Options {
|
||||
SC::Check => {
|
||||
let _span = info_span!("cli.templates.check").entered();
|
||||
|
||||
let config: TemplatesConfig = root.load_config()?;
|
||||
let template_config: TemplatesConfig = root.load_config()?;
|
||||
let branding_config: BrandingConfig = root.load_config()?;
|
||||
let matrix_config: MatrixConfig = root.load_config()?;
|
||||
|
||||
let clock = SystemClock::default();
|
||||
// XXX: we should disallow SeedableRng::from_entropy
|
||||
let mut rng = rand_chacha::ChaChaRng::from_entropy();
|
||||
let url_builder =
|
||||
mas_router::UrlBuilder::new("https://example.com/".parse()?, None, None);
|
||||
let templates = templates_from_config(&config, &url_builder).await?;
|
||||
let templates = templates_from_config(
|
||||
&template_config,
|
||||
&branding_config,
|
||||
&url_builder,
|
||||
&matrix_config.homeserver,
|
||||
)
|
||||
.await?;
|
||||
templates.check_render(clock.now(), &mut rng)?;
|
||||
|
||||
Ok(())
|
||||
|
@@ -44,7 +44,13 @@ impl Options {
|
||||
);
|
||||
|
||||
// Load and compile the templates
|
||||
let templates = templates_from_config(&config.templates, &url_builder).await?;
|
||||
let templates = templates_from_config(
|
||||
&config.templates,
|
||||
&config.branding,
|
||||
&url_builder,
|
||||
&config.matrix.homeserver,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let mailer = mailer_from_config(&config.email, &templates)?;
|
||||
mailer.test_connection().await?;
|
||||
|
@@ -16,14 +16,14 @@ use std::time::Duration;
|
||||
|
||||
use anyhow::Context;
|
||||
use mas_config::{
|
||||
DatabaseConfig, DatabaseConnectConfig, EmailConfig, EmailSmtpMode, EmailTransportConfig,
|
||||
PasswordsConfig, PolicyConfig, TemplatesConfig,
|
||||
BrandingConfig, DatabaseConfig, DatabaseConnectConfig, EmailConfig, EmailSmtpMode,
|
||||
EmailTransportConfig, PasswordsConfig, PolicyConfig, TemplatesConfig,
|
||||
};
|
||||
use mas_email::{MailTransport, Mailer};
|
||||
use mas_handlers::{passwords::PasswordManager, ActivityTracker};
|
||||
use mas_policy::PolicyFactory;
|
||||
use mas_router::UrlBuilder;
|
||||
use mas_templates::{TemplateLoadingError, Templates};
|
||||
use mas_templates::{SiteBranding, TemplateLoadingError, Templates};
|
||||
use sqlx::{
|
||||
postgres::{PgConnectOptions, PgPoolOptions},
|
||||
ConnectOptions, PgConnection, PgPool,
|
||||
@@ -116,13 +116,34 @@ pub async fn policy_factory_from_config(
|
||||
|
||||
pub async fn templates_from_config(
|
||||
config: &TemplatesConfig,
|
||||
branding: &BrandingConfig,
|
||||
url_builder: &UrlBuilder,
|
||||
server_name: &str,
|
||||
) -> Result<Templates, TemplateLoadingError> {
|
||||
let mut site_branding = SiteBranding::new(server_name);
|
||||
|
||||
if let Some(service_name) = branding.service_name.as_deref() {
|
||||
site_branding = site_branding.with_service_name(service_name);
|
||||
}
|
||||
|
||||
if let Some(policy_uri) = &branding.policy_uri {
|
||||
site_branding = site_branding.with_policy_uri(policy_uri.as_str());
|
||||
}
|
||||
|
||||
if let Some(tos_uri) = &branding.tos_uri {
|
||||
site_branding = site_branding.with_tos_uri(tos_uri.as_str());
|
||||
}
|
||||
|
||||
if let Some(imprint) = branding.imprint.as_deref() {
|
||||
site_branding = site_branding.with_imprint(imprint);
|
||||
}
|
||||
|
||||
Templates::load(
|
||||
config.path.clone(),
|
||||
url_builder.clone(),
|
||||
config.assets_manifest.clone(),
|
||||
config.translations_path.clone(),
|
||||
site_branding,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
Reference in New Issue
Block a user