Struct pwquality::PWQuality
[−]
[src]
pub struct PWQuality { /* fields omitted */ }
Representation of an instance of pwquality
.
Each instance has its own settings, that can be
changed.
Methods
impl PWQuality
[src]
fn new() -> Self
[src]
Creates a new isntance with default settings.
fn from_default_config() -> Result<Self, Error>
[src]
Creates a new instance with default configuration.
fn from_config<P: AsRef<Path>>(config_path: P) -> Result<Self, Error>
[src]
Creates a new instance with given configuration file.
fn from_optional_config<P: AsRef<Path>>(
config_path: Option<P>
) -> Result<Self, Error>
[src]
config_path: Option<P>
) -> Result<Self, Error>
Creates a new instance with given configuration file.
If None
is passed, then default configuration is used.
fn set_min_diff(&self, min: Option<i32>)
[src]
Sets the minimum number of changes required between old and new password.
A value of None
disables the check.
fn get_min_diff(&self) -> Option<i32>
[src]
Returns the minimum number of changes required between old and new password.
Returns None
if check is disabled.
fn set_min_length(&self, min: i32)
[src]
Sets the minimum accepted length for a password.
Any number less than 6
will be replaced by 6
.
fn get_min_length(&self) -> i32
[src]
Returns the minimum accepted length for a password.
fn set_digit_credit(&self, credit: i32)
[src]
Sets the digit credit:
- if
credit >= 0
, it represents the maximum credit for having digits in a password; - if
credit < 0
, it represents the minimum number of digits required in a password.
fn get_digit_credit(&self) -> i32
[src]
Returns the digit credit:
- if
credit >= 0
, it represents the maximum credit for having digits in a password; - if
credit < 0
, it represents the minimum number of digits required in a password.
fn set_uppercase_credit(&self, credit: i32)
[src]
Sets the uppercase letter credit:
- if
credit >= 0
, it represents the maximum credit for having uppercase letters in a password; - if
credit < 0
, it represents the minimum number of uppercase letters required in a password.
fn get_uppercase_credit(&self) -> i32
[src]
Returns the uppercase letter credit:
- if
credit >= 0
, it represents the maximum credit for having uppercase letters in a password; - if
credit < 0
, it represents the minimum number of uppercase letters required in a password.
fn set_lowercase_credit(&self, credit: i32)
[src]
Sets the lowercase letter credit:
- if
credit >= 0
, it represents the maximum credit for having lowercase letters in a password; - if
credit < 0
, it represents the minimum number of lowercase letters required in a password.
fn get_lowercase_credit(&self) -> i32
[src]
Returns the lowercase letter credit:
- if
credit >= 0
, it represents the maximum credit for having lowercase letters in a password; - if
credit < 0
, it represents the minimum number of lowercase letters required in a password.
fn set_other_credit(&self, credit: i32)
[src]
Sets the other character credit:
- if
credit >= 0
, it represents the maximum credit for having other characters in a password; - if
credit < 0
, it represents the minimum number of other characters required in a password.
fn get_other_credit(&self) -> i32
[src]
Returns the other character credit:
- if
credit >= 0
, it represents the maximum credit for having other characters in a password; - if
credit < 0
, it represents the minimum number of other characters required in a password.
fn set_min_classes(&self, min: i32)
[src]
Sets the minimum required number of classes in a password. There a four available classes:
- digits:
[0-9]
- lowercase letters:
[a-z]
- uppercase letters:
[A-Z]
- other characters:
!$%&#…
fn get_min_classes(&self) -> i32
[src]
Returns the minimum required number of classes in a password.
fn set_max_repeat(&self, max: i32)
[src]
Sets the maximum size of allowed repeated characters sequences in a password.
A value of 0
disables this check.
fn get_max_repeat(&self) -> i32
[src]
Returns the maximum size of allowed repeated characters sequences in a password.
fn set_max_class_repeat(&self, max: i32)
[src]
Sets the maximum size of allowed characters sequences of a same class in a
password.
A value of 0
disables this check,
fn get_max_class_repeat(&self) -> i32
[src]
Returns the maximum size of allowed characters sequences of a same class in a password.
fn set_max_sequence(&self, max: i32)
[src]
Sets the maximum size allowed for monotonic character sequences such as 12345
or fedcb
in a password.
A value of 0
disables this check.
fn get_max_sequence(&self) -> i32
[src]
Returns the maximum size allowed for monotonic character sequences such as 12345
or fedcb
in a password.
fn set_gecos_check(&self, check: bool)
[src]
Sets whether the check for the presence of words longer than 3 characters present in the
passwd
GECOS field of a user in a password is enabled.
fn get_gecos_check(&self) -> bool
[src]
Returns whether the check for the presence of words longer than 3 characters present in the
passwd
GECOS field of a user in a password is enabled.
fn set_dictionary_check(&self, check: bool)
[src]
Sets whether the check that a password is contained in a dictionary is enabled.
fn get_dictionary_check(&self) -> bool
[src]
Returns whether the check that a password is contained in a dictionary is enabled.
fn set_user_check(&self, check: bool)
[src]
Sets whether the check of username presence in a password is enabled.
fn get_user_check(&self) -> bool
[src]
Returns whether the check of username presence in a password is enabled.
fn set_enforcing(&self, check: bool)
[src]
Sets whether a password that does not pass the checks should be rejected.
fn get_enforcing(&self) -> bool
[src]
Returns whether a password that does not pass the checks should be rejected.
fn set_dictionary_path(&self, path: String) -> Result<(), Error>
[src]
Sets the path to the dictionary to use (other than the default cracklib one).
fn get_dictionary_path(&self) -> Result<Option<String>, Error>
[src]
Returns the path to the dictionary to use (if any other than the default cracklib one).
fn set_bad_words(&self, bad_words: Vec<String>) -> Result<(), Error>
[src]
Sets the list of words longer than 3 characters that are not allowed in a password. Words cannot contain whitespaces, otherwise will be considered as separate words.
fn get_bad_words(&self) -> Result<Vec<String>, Error>
[src]
Returns the list of forbidden words in a password.
fn generate_password(&self, entropy: i32) -> Result<String, Error>
[src]
Generates a password with the given number of bits of entropy.
fn check(
&self,
password: String,
old_password: Option<String>,
username: Option<String>
) -> Result<i32, Error>
[src]
&self,
password: String,
old_password: Option<String>,
username: Option<String>
) -> Result<i32, Error>
Checks a password according to the settings and returns the computed score.