config: Add a minimum password length

This commit is contained in:
Valentin Tolmer 2021-10-07 18:20:50 +02:00 committed by nitnelave
parent 1ec533bd9b
commit d9abcd335d
2 changed files with 5 additions and 1 deletions

View File

@ -38,6 +38,7 @@
## Admin password. ## Admin password.
## Password for the admin account, both for the LDAP bind and for the ## Password for the admin account, both for the LDAP bind and for the
## administration interface. ## administration interface.
## It should be minimum 8 characters long.
## You can set it with the LDAP_USER_PASS environment variable. ## You can set it with the LDAP_USER_PASS environment variable.
## Note: you can create another admin user for LDAP/administration, this ## Note: you can create another admin user for LDAP/administration, this
## is just the default one. ## is just the default one.

View File

@ -11,7 +11,7 @@ use crate::{
infra::{cli::*, configuration::Configuration, db_cleaner::Scheduler}, infra::{cli::*, configuration::Configuration, db_cleaner::Scheduler},
}; };
use actix::Actor; use actix::Actor;
use anyhow::{Context, Result}; use anyhow::{bail, Context, Result};
use futures_util::TryFutureExt; use futures_util::TryFutureExt;
use log::*; use log::*;
@ -19,6 +19,9 @@ mod domain;
mod infra; mod infra;
async fn create_admin_user(handler: &SqlBackendHandler, config: &Configuration) -> Result<()> { async fn create_admin_user(handler: &SqlBackendHandler, config: &Configuration) -> Result<()> {
if config.ldap_user_pass.len() < 8 {
bail!("Minimum password length is 8 characters");
}
handler handler
.create_user(CreateUserRequest { .create_user(CreateUserRequest {
user_id: config.ldap_user_dn.clone(), user_id: config.ldap_user_dn.clone(),