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
Add instance privacy policy, TOS and imprint, and loads of design cleanups
This commit is contained in:
63
crates/config/src/sections/branding.rs
Normal file
63
crates/config/src/sections/branding.rs
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright 2023 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.
|
||||
|
||||
use async_trait::async_trait;
|
||||
use rand::Rng;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use crate::ConfigurationSection;
|
||||
|
||||
/// Configuration section for tweaking the branding of the service
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, Default)]
|
||||
pub struct BrandingConfig {
|
||||
/// A human-readable name. Defaults to the server's address.
|
||||
pub service_name: Option<String>,
|
||||
|
||||
/// Link to a privacy policy, displayed in the footer of web pages and
|
||||
/// emails. It is also advertised to clients through the `op_policy_uri`
|
||||
/// OIDC provider metadata.
|
||||
pub policy_uri: Option<Url>,
|
||||
|
||||
/// Link to a terms of service document, displayed in the footer of web
|
||||
/// pages and emails. It is also advertised to clients through the
|
||||
/// `op_tos_uri` OIDC provider metadata.
|
||||
pub tos_uri: Option<Url>,
|
||||
|
||||
/// Legal imprint, displayed in the footer in the footer of web pages and
|
||||
/// emails.
|
||||
pub imprint: Option<String>,
|
||||
|
||||
/// Logo displayed in some web pages.
|
||||
pub logo_uri: Option<Url>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ConfigurationSection for BrandingConfig {
|
||||
fn path() -> &'static str {
|
||||
"branding"
|
||||
}
|
||||
|
||||
async fn generate<R>(_rng: R) -> anyhow::Result<Self>
|
||||
where
|
||||
R: Rng + Send,
|
||||
{
|
||||
Ok(Self::default())
|
||||
}
|
||||
|
||||
fn test() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ use rand::Rng;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
mod branding;
|
||||
mod clients;
|
||||
mod database;
|
||||
mod email;
|
||||
@@ -31,6 +32,7 @@ mod templates;
|
||||
mod upstream_oauth2;
|
||||
|
||||
pub use self::{
|
||||
branding::BrandingConfig,
|
||||
clients::{ClientAuthMethodConfig, ClientConfig, ClientsConfig},
|
||||
database::{ConnectConfig as DatabaseConnectConfig, DatabaseConfig},
|
||||
email::{EmailConfig, EmailSmtpMode, EmailTransportConfig},
|
||||
@@ -103,6 +105,10 @@ pub struct RootConfig {
|
||||
#[serde(default)]
|
||||
pub upstream_oauth2: UpstreamOAuth2Config,
|
||||
|
||||
/// Configuration section for tweaking the branding of the service
|
||||
#[serde(default)]
|
||||
pub branding: BrandingConfig,
|
||||
|
||||
/// Experimental configuration options
|
||||
#[serde(default)]
|
||||
pub experimental: ExperimentalConfig,
|
||||
@@ -130,6 +136,7 @@ impl ConfigurationSection for RootConfig {
|
||||
matrix: MatrixConfig::generate(&mut rng).await?,
|
||||
policy: PolicyConfig::generate(&mut rng).await?,
|
||||
upstream_oauth2: UpstreamOAuth2Config::generate(&mut rng).await?,
|
||||
branding: BrandingConfig::generate(&mut rng).await?,
|
||||
experimental: ExperimentalConfig::generate(&mut rng).await?,
|
||||
})
|
||||
}
|
||||
@@ -147,6 +154,7 @@ impl ConfigurationSection for RootConfig {
|
||||
matrix: MatrixConfig::test(),
|
||||
policy: PolicyConfig::test(),
|
||||
upstream_oauth2: UpstreamOAuth2Config::test(),
|
||||
branding: BrandingConfig::test(),
|
||||
experimental: ExperimentalConfig::test(),
|
||||
}
|
||||
}
|
||||
@@ -178,6 +186,9 @@ pub struct AppConfig {
|
||||
#[serde(default)]
|
||||
pub policy: PolicyConfig,
|
||||
|
||||
#[serde(default)]
|
||||
pub branding: BrandingConfig,
|
||||
|
||||
#[serde(default)]
|
||||
pub experimental: ExperimentalConfig,
|
||||
}
|
||||
@@ -201,6 +212,7 @@ impl ConfigurationSection for AppConfig {
|
||||
secrets: SecretsConfig::generate(&mut rng).await?,
|
||||
matrix: MatrixConfig::generate(&mut rng).await?,
|
||||
policy: PolicyConfig::generate(&mut rng).await?,
|
||||
branding: BrandingConfig::generate(&mut rng).await?,
|
||||
experimental: ExperimentalConfig::generate(&mut rng).await?,
|
||||
})
|
||||
}
|
||||
@@ -215,6 +227,7 @@ impl ConfigurationSection for AppConfig {
|
||||
secrets: SecretsConfig::test(),
|
||||
matrix: MatrixConfig::test(),
|
||||
policy: PolicyConfig::test(),
|
||||
branding: BrandingConfig::test(),
|
||||
experimental: ExperimentalConfig::test(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user