mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
Create admin user by default
This commit is contained in:
parent
5a70f2ebc2
commit
8e369016da
@ -39,7 +39,7 @@ fn passwords_match(encrypted_password: &str, clear_password: &str, pepper: &str)
|
|||||||
encrypted_password,
|
encrypted_password,
|
||||||
clear_password.as_bytes(),
|
clear_password.as_bytes(),
|
||||||
pepper.as_bytes(),
|
pepper.as_bytes(),
|
||||||
/*additional_data=*/b"",
|
/*additional_data=*/ b"",
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
log::error!("Error checking password: {}", e);
|
log::error!("Error checking password: {}", e);
|
||||||
|
17
src/main.rs
17
src/main.rs
@ -1,6 +1,8 @@
|
|||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
use crate::{
|
use crate::{
|
||||||
domain::{sql_backend_handler::SqlBackendHandler, sql_tables::PoolOptions},
|
domain::{
|
||||||
|
handler::BackendHandler, sql_backend_handler::SqlBackendHandler, sql_tables::PoolOptions,
|
||||||
|
},
|
||||||
infra::{configuration::Configuration, db_cleaner::Scheduler},
|
infra::{configuration::Configuration, db_cleaner::Scheduler},
|
||||||
};
|
};
|
||||||
use actix::Actor;
|
use actix::Actor;
|
||||||
@ -11,6 +13,18 @@ use log::*;
|
|||||||
mod domain;
|
mod domain;
|
||||||
mod infra;
|
mod infra;
|
||||||
|
|
||||||
|
async fn create_admin_user(handler: &SqlBackendHandler, config: &Configuration) {
|
||||||
|
handler
|
||||||
|
.create_user(lldap_model::CreateUserRequest {
|
||||||
|
user_id: config.ldap_user_dn.clone(),
|
||||||
|
password: config.ldap_user_pass.clone(),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|e| warn!("Error creating admin user: {}", e))
|
||||||
|
// TODO: create admin group, add it to the group
|
||||||
|
}
|
||||||
|
|
||||||
async fn run_server(config: Configuration) -> Result<()> {
|
async fn run_server(config: Configuration) -> Result<()> {
|
||||||
let sql_pool = PoolOptions::new()
|
let sql_pool = PoolOptions::new()
|
||||||
.max_connections(5)
|
.max_connections(5)
|
||||||
@ -18,6 +32,7 @@ async fn run_server(config: Configuration) -> Result<()> {
|
|||||||
.await?;
|
.await?;
|
||||||
domain::sql_tables::init_table(&sql_pool).await?;
|
domain::sql_tables::init_table(&sql_pool).await?;
|
||||||
let backend_handler = SqlBackendHandler::new(config.clone(), sql_pool.clone());
|
let backend_handler = SqlBackendHandler::new(config.clone(), sql_pool.clone());
|
||||||
|
create_admin_user(&backend_handler, &config).await;
|
||||||
let server_builder = infra::ldap_server::build_ldap_server(
|
let server_builder = infra::ldap_server::build_ldap_server(
|
||||||
&config,
|
&config,
|
||||||
backend_handler.clone(),
|
backend_handler.clone(),
|
||||||
|
Loading…
Reference in New Issue
Block a user