Skip to content
2 changes: 1 addition & 1 deletion crates/defguard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async fn main() -> Result<(), anyhow::Error> {
Settings::init_defaults(&pool).await?;
// initialize global settings struct
initialize_current_settings(&pool).await?;
Settings::ensure_secret_key(&pool, &config).await?;
Settings::ensure_secret_key(&pool).await?;
let mut settings = Settings::get_current_settings();

if wizard_flags.initial_wizard_in_progress && !wizard_flags.initial_wizard_completed {
Expand Down
50 changes: 0 additions & 50 deletions crates/defguard_common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@ pub struct DefGuardConfig {
#[arg(long, env = "DEFGUARD_GRPC_KEY")]
pub grpc_key: Option<String>,

#[arg(
long,
env = "DEFGUARD_DEFAULT_ADMIN_PASSWORD",
default_value = "pass123"
)]
#[serde(skip_serializing)]
// TODO: Deprecate this, since we have initial setup now.
// We use it in some dev/test scenarios still so the approach will need to be changed there.
pub default_admin_password: SecretString,

#[arg(long, env = "DEFGUARD_OPENID_KEY", value_parser = Self::parse_openid_key)]
#[serde(skip_serializing)]
pub openid_signing_key: Option<RsaPrivateKey>,
Expand All @@ -98,10 +88,6 @@ pub struct DefGuardConfig {
#[deprecated(since = "2.0.0", note = "Use Settings.defguard_url instead")]
pub url: Url,

#[arg(long, env = "DEFGUARD_GRPC_URL", value_parser = Url::parse)]
#[deprecated(since = "2.0.0", note = "Use Settings.grpc_url instead")]
pub grpc_url: Option<Url>,

#[arg(long, env = "DEFGUARD_DISABLE_STATS_PURGE")]
#[deprecated(since = "2.0.0", note = "Use Settings.disable_stats_purge instead")]
pub disable_stats_purge: Option<bool>,
Expand Down Expand Up @@ -252,21 +238,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.");
// TODO(jck)
// self.initialize_rp_id(&url);
self.initialize_cookie_domain(&url);
}

// fn initialize_rp_id(&mut self, url: &Url) {
// if self.webauthn_rp_id.is_none() {
// self.webauthn_rp_id = Some(
// url.domain()
// .expect("Unable to get domain for server URL.")
// .to_string(),
// );
// }
// }

fn initialize_cookie_domain(&mut self, url: &Url) {
if self.cookie_domain.is_none() {
self.cookie_domain = Some(
Expand Down Expand Up @@ -316,30 +290,6 @@ mod tests {
DefGuardConfig::command().debug_assert();
}

// #[test]
// fn test_generate_rp_id() {
// unsafe {
// env::remove_var("DEFGUARD_WEBAUTHN_RP_ID");
// }

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

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

// unsafe {
// env::set_var("DEFGUARD_WEBAUTHN_RP_ID", "example.com");
// }

// let config = DefGuardConfig::new();

// assert_eq!(config.webauthn_rp_id, Some("example.com".to_string()));
// }

#[test]
fn test_generate_cookie_domain() {
unsafe {
Expand Down
Loading