From db2b5cbae0546b9dc7b39b1b3e9dcbb281a8bd30 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Sun, 21 Nov 2021 18:30:24 +0100 Subject: [PATCH] server: Add http_url to the configuration --- lldap_config.docker_template.toml | 3 +++ server/src/infra/cli.rs | 5 +++++ server/src/infra/configuration.rs | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/lldap_config.docker_template.toml b/lldap_config.docker_template.toml index be992bd..e743545 100644 --- a/lldap_config.docker_template.toml +++ b/lldap_config.docker_template.toml @@ -10,6 +10,9 @@ ## administration. #http_port = 17170 +## The public URL of the server, for password reset links. +#http_url = "http://localhost" + ## Random secret for JWT signature. ## This secret should be random, and should be shared with application ## servers that need to consume the JWTs. diff --git a/server/src/infra/cli.rs b/server/src/infra/cli.rs index 2fe7cf5..e7fbd8a 100644 --- a/server/src/infra/cli.rs +++ b/server/src/infra/cli.rs @@ -10,6 +10,7 @@ pub struct CLIOpts { pub command: Command, } +#[allow(clippy::large_enum_variant)] #[derive(Debug, Clap, Clone)] pub enum Command { /// Export the GraphQL schema to *.graphql. @@ -56,6 +57,10 @@ pub struct RunOpts { #[clap(long, env = "LLDAP_HTTP_PORT")] pub http_port: Option, + /// URL of the server, for password reset links. + #[clap(long, env = "LLDAP_HTTP_URL")] + pub http_url: Option, + #[clap(flatten)] pub smtp_opts: SmtpOpts, } diff --git a/server/src/infra/configuration.rs b/server/src/infra/configuration.rs index 3cee6c8..5ef4a0e 100644 --- a/server/src/infra/configuration.rs +++ b/server/src/infra/configuration.rs @@ -64,6 +64,8 @@ pub struct Configuration { pub key_file: String, #[builder(default)] pub smtp_options: MailOptions, + #[builder(default = r#"String::from("http://localhost")"#)] + pub http_url: String, #[serde(skip)] #[builder(field(private), setter(strip_option))] server_setup: Option, @@ -152,6 +154,10 @@ impl ConfigOverrider for RunOpts { if let Some(port) = self.http_port { config.http_port = port; } + + if let Some(url) = self.http_url.as_ref() { + config.http_url = url.to_string(); + } self.smtp_opts.override_config(config); } }