Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/defguard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async fn main() -> Result<(), anyhow::Error> {
pool.clone(),
settings.stats_purge_frequency(),
settings.stats_purge_threshold()
), if !settings.disable_stats_purge =>
), if settings.enable_stats_purge =>
error!("Periodic stats purge task returned early: {res:?}"),
res = run_periodic_license_check(&pool, proxy_control_tx) =>
error!("Periodic license check task returned early: {res:?}"),
Expand Down
34 changes: 4 additions & 30 deletions crates/defguard_common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,13 @@ pub struct DefGuardConfig {
#[serde(skip_serializing)]
pub openid_signing_key: Option<RsaPrivateKey>,

// relying party id and relying party origin for WebAuthn
#[arg(long, env = "DEFGUARD_WEBAUTHN_RP_ID")]
#[deprecated(since = "2.0.0", note = "Use Settings.webauthn_rp_id instead")]
pub webauthn_rp_id: Option<String>,

#[arg(long, env = "DEFGUARD_URL", value_parser = Url::parse, default_value = "http://localhost:8000")]
#[serde(skip_serializing)]
#[deprecated(since = "2.0.0", note = "Use Settings.defguard_url instead")]
pub url: Url,

#[arg(long, env = "DEFGUARD_DISABLE_STATS_PURGE")]
#[deprecated(since = "2.0.0", note = "Use Settings.disable_stats_purge instead")]
#[deprecated(since = "2.0.0", note = "Use Settings.enable_stats_purge instead")]
pub disable_stats_purge: Option<bool>,

#[arg(long, env = "DEFGUARD_STATS_PURGE_FREQUENCY")]
Expand Down Expand Up @@ -240,17 +235,9 @@ impl DefGuardConfig {

/// Initialize values that depend on Settings.
pub fn initialize_post_settings(&mut self) {
let url = Settings::url().expect("Unable to parse Defguard URL.");
self.initialize_cookie_domain(&url);
}

fn initialize_cookie_domain(&mut self, url: &Url) {
if self.cookie_domain.is_none() {
self.cookie_domain = Some(
url.domain()
.expect("Unable to get domain for server URL.")
.to_string(),
);
let settings = Settings::get_current_settings();
self.cookie_domain = settings.cookie_domain().ok();
}
}

Expand Down Expand Up @@ -294,20 +281,7 @@ mod tests {
}

#[test]
fn test_generate_cookie_domain() {
unsafe {
env::remove_var("DEFGUARD_COOKIE_DOMAIN");
}

let url = Url::parse("https://defguard.example.com").unwrap();
let mut config = DefGuardConfig::new();
config.initialize_cookie_domain(&url);

assert_eq!(
config.cookie_domain,
Some("defguard.example.com".to_string())
);

fn test_cookie_domain_env_override() {
unsafe {
env::set_var("DEFGUARD_COOKIE_DOMAIN", "example.com");
}
Expand Down
Loading
Loading