1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Make password-based login optional

This commit is contained in:
Quentin Gliech
2023-05-23 14:20:27 +02:00
parent 25f045130e
commit d2d68e9a27
16 changed files with 572 additions and 118 deletions

View File

@ -31,9 +31,17 @@ fn default_schemes() -> Vec<HashingScheme> {
}]
}
fn default_enabled() -> bool {
true
}
/// User password hashing config
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct PasswordsConfig {
/// Whether password-based authentication is enabled
#[serde(default = "default_enabled")]
enabled: bool,
#[serde(default = "default_schemes")]
schemes: Vec<HashingScheme>,
}
@ -41,6 +49,7 @@ pub struct PasswordsConfig {
impl Default for PasswordsConfig {
fn default() -> Self {
Self {
enabled: default_enabled(),
schemes: default_schemes(),
}
}
@ -65,6 +74,12 @@ impl ConfigurationSection<'_> for PasswordsConfig {
}
impl PasswordsConfig {
/// Whether password-based authentication is enabled
#[must_use]
pub fn enabled(&self) -> bool {
self.enabled
}
/// Load the password hashing schemes defined by the config
///
/// # Errors