Misc cleanup

This commit is contained in:
Valentin Tolmer 2021-03-12 09:33:43 +01:00
parent 86b89a00cc
commit 03e6afda69
4 changed files with 11 additions and 7 deletions

View File

@ -38,7 +38,9 @@ impl SqlBackendHandler {
impl BackendHandler for SqlBackendHandler { impl BackendHandler for SqlBackendHandler {
fn bind(&mut self, request: BindRequest) -> Result<()> { 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; self.authenticated = true;
Ok(()) Ok(())
} else { } else {

View File

@ -13,8 +13,9 @@ pub struct Configuration {
pub ldaps_port: u16, pub ldaps_port: u16,
pub http_port: u16, pub http_port: u16,
pub secret_pepper: String, pub secret_pepper: String,
pub admin_dn: String, pub ldap_user_dn: String,
pub admin_password: String, pub ldap_user_pass: String,
pub database_url: String,
pub verbose: bool, pub verbose: bool,
} }
@ -25,8 +26,9 @@ impl Default for Configuration {
ldaps_port: 6360, ldaps_port: 6360,
http_port: 17170, http_port: 17170,
secret_pepper: String::from("secretsecretpepper"), secret_pepper: String::from("secretsecretpepper"),
admin_dn: String::new(), ldap_user_dn: String::new(),
admin_password: String::new(), ldap_user_pass: String::new(),
database_url: String::from("sqlite://users.db?mode=rwc"),
verbose: false, verbose: false,
} }
} }

View File

@ -87,7 +87,7 @@ impl<Backend: BackendHandler> LdapHandler<Backend> {
mod tests { mod tests {
use super::*; use super::*;
use crate::domain::handler::MockTestBackendHandler; use crate::domain::handler::MockTestBackendHandler;
use mockall::{mock, predicate::*}; use mockall::predicate::eq;
#[test] #[test]
fn test_bind() { fn test_bind() {

View File

@ -10,7 +10,7 @@ mod infra;
async fn run_server(config: Configuration) -> Result<()> { async fn run_server(config: Configuration) -> Result<()> {
let sql_pool = AnyPoolOptions::new() let sql_pool = AnyPoolOptions::new()
.max_connections(5) .max_connections(5)
.connect("sqlite://users.db?mode=rwc") .connect(&config.database_url)
.await?; .await?;
let backend_handler = domain::handler::SqlBackendHandler::new(config.clone(), sql_pool.clone()); let backend_handler = domain::handler::SqlBackendHandler::new(config.clone(), sql_pool.clone());
let server_builder = infra::ldap_server::build_ldap_server( let server_builder = infra::ldap_server::build_ldap_server(