|
|
@ -628,6 +628,11 @@ make_config! { |
|
|
/// This setting applies globally to all users.
|
|
|
/// This setting applies globally to all users.
|
|
|
incomplete_2fa_time_limit: u16, true, def, 3; |
|
|
incomplete_2fa_time_limit: u16, true, def, 3; |
|
|
|
|
|
|
|
|
|
|
|
/// Password generator policy |> Optional global password generator policy, enforced for all
|
|
|
|
|
|
/// users as if set by an organization. Uses the Bitwarden policy data format. Ex format:
|
|
|
|
|
|
/// '{"overridePasswordType":null,"minLength":16,"useUpper":true,"useLower":true,"useNumbers":true,"useSpecial":false,"minNumbers":1,"minSpecial":1,"minNumberWords":3,"capitalize":false,"includeNumber":false}'
|
|
|
|
|
|
password_generator_policy: String, true, option; |
|
|
|
|
|
|
|
|
/// Disable icon downloads |> Set to true to disable icon downloading in the internal icon service.
|
|
|
/// Disable icon downloads |> Set to true to disable icon downloading in the internal icon service.
|
|
|
/// This still serves existing icons from $ICON_CACHE_FOLDER, without generating any external
|
|
|
/// This still serves existing icons from $ICON_CACHE_FOLDER, without generating any external
|
|
|
/// network requests. $ICON_CACHE_TTL must also be set to 0; otherwise, the existing icons
|
|
|
/// network requests. $ICON_CACHE_TTL must also be set to 0; otherwise, the existing icons
|
|
|
@ -1161,6 +1166,8 @@ fn validate_config(cfg: &ConfigItems, on_update: bool) -> Result<(), Error> { |
|
|
validate_sso_master_password_policy(cfg.sso_master_password_policy.as_ref())?; |
|
|
validate_sso_master_password_policy(cfg.sso_master_password_policy.as_ref())?; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
validate_password_generator_policy(cfg.password_generator_policy.as_ref())?; |
|
|
|
|
|
|
|
|
if cfg._enable_yubico { |
|
|
if cfg._enable_yubico { |
|
|
if cfg.yubico_client_id.is_some() != cfg.yubico_secret_key.is_some() { |
|
|
if cfg.yubico_client_id.is_some() != cfg.yubico_secret_key.is_some() { |
|
|
err!("Both `YUBICO_CLIENT_ID` and `YUBICO_SECRET_KEY` must be set for Yubikey OTP support") |
|
|
err!("Both `YUBICO_CLIENT_ID` and `YUBICO_SECRET_KEY` must be set for Yubikey OTP support") |
|
|
@ -1404,6 +1411,21 @@ fn validate_sso_master_password_policy( |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn validate_password_generator_policy( |
|
|
|
|
|
password_generator_policy: Option<&String>, |
|
|
|
|
|
) -> Result<Option<serde_json::Value>, Error> { |
|
|
|
|
|
let policy = password_generator_policy.as_ref().map(|pgp| serde_json::from_str::<serde_json::Value>(pgp)); |
|
|
|
|
|
|
|
|
|
|
|
match policy { |
|
|
|
|
|
None => Ok(None), |
|
|
|
|
|
Some(Ok(jsobject @ serde_json::Value::Object(_))) => Ok(Some(jsobject)), |
|
|
|
|
|
Some(Ok(_)) => err!("Invalid password_generator_policy: parsed value is not a JSON object"), |
|
|
|
|
|
Some(Err(error)) => { |
|
|
|
|
|
err!(format!("Invalid password_generator_policy ({error}), Ensure that it's correctly escaped with ''")) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// Extracts an RFC 6454 web origin from a URL.
|
|
|
/// Extracts an RFC 6454 web origin from a URL.
|
|
|
fn extract_url_origin(url: &str) -> String { |
|
|
fn extract_url_origin(url: &str) -> String { |
|
|
match Url::parse(url) { |
|
|
match Url::parse(url) { |
|
|
@ -1774,6 +1796,10 @@ impl Config { |
|
|
validate_sso_master_password_policy(self.sso_master_password_policy().as_ref()).ok().flatten() |
|
|
validate_sso_master_password_policy(self.sso_master_password_policy().as_ref()).ok().flatten() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn password_generator_policy_value(&self) -> Option<serde_json::Value> { |
|
|
|
|
|
validate_password_generator_policy(self.password_generator_policy().as_ref()).ok().flatten() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
pub fn sso_scopes_vec(&self) -> Vec<String> { |
|
|
pub fn sso_scopes_vec(&self) -> Vec<String> { |
|
|
self.sso_scopes().split_whitespace().map(str::to_owned).collect() |
|
|
self.sso_scopes().split_whitespace().map(str::to_owned).collect() |
|
|
} |
|
|
} |
|
|
|