From 03e6afda6910831c40ec83c9f6d27d9bf3e4bd1e Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Fri, 12 Mar 2021 09:33:43 +0100 Subject: [PATCH] Misc cleanup --- src/domain/handler.rs | 4 +++- src/infra/configuration.rs | 10 ++++++---- src/infra/ldap_handler.rs | 2 +- src/main.rs | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/domain/handler.rs b/src/domain/handler.rs index 587c843..582a691 100644 --- a/src/domain/handler.rs +++ b/src/domain/handler.rs @@ -38,7 +38,9 @@ impl SqlBackendHandler { impl BackendHandler for SqlBackendHandler { fn bind(&mut self, request: BindRequest) -> Result<()> { - if request.name == self.config.admin_dn && request.password == self.config.admin_password { + if request.name == self.config.ldap_user_dn + && request.password == self.config.ldap_user_pass + { self.authenticated = true; Ok(()) } else { diff --git a/src/infra/configuration.rs b/src/infra/configuration.rs index b18eb12..7e38d81 100644 --- a/src/infra/configuration.rs +++ b/src/infra/configuration.rs @@ -13,8 +13,9 @@ pub struct Configuration { pub ldaps_port: u16, pub http_port: u16, pub secret_pepper: String, - pub admin_dn: String, - pub admin_password: String, + pub ldap_user_dn: String, + pub ldap_user_pass: String, + pub database_url: String, pub verbose: bool, } @@ -25,8 +26,9 @@ impl Default for Configuration { ldaps_port: 6360, http_port: 17170, secret_pepper: String::from("secretsecretpepper"), - admin_dn: String::new(), - admin_password: String::new(), + ldap_user_dn: String::new(), + ldap_user_pass: String::new(), + database_url: String::from("sqlite://users.db?mode=rwc"), verbose: false, } } diff --git a/src/infra/ldap_handler.rs b/src/infra/ldap_handler.rs index 2c9a29a..a7ca3dc 100644 --- a/src/infra/ldap_handler.rs +++ b/src/infra/ldap_handler.rs @@ -87,7 +87,7 @@ impl LdapHandler { mod tests { use super::*; use crate::domain::handler::MockTestBackendHandler; - use mockall::{mock, predicate::*}; + use mockall::predicate::eq; #[test] fn test_bind() { diff --git a/src/main.rs b/src/main.rs index 26db4bb..9cf0a8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ mod infra; async fn run_server(config: Configuration) -> Result<()> { let sql_pool = AnyPoolOptions::new() .max_connections(5) - .connect("sqlite://users.db?mode=rwc") + .connect(&config.database_url) .await?; let backend_handler = domain::handler::SqlBackendHandler::new(config.clone(), sql_pool.clone()); let server_builder = infra::ldap_server::build_ldap_server(