module documentation

Undocumented

Class ​Common​Password​Validator Validate whether the password is a common password.
Class ​Minimum​Length​Validator Validate whether the password is of a minimum length.
Class ​Numeric​Password​Validator Validate whether the password is alphanumeric.
Class ​User​Attribute​Similarity​Validator Validate whether the password is sufficiently different from the user's attributes.
Function get​_password​_validators Undocumented
Function password​_changed Inform all validators that have implemented a password_changed() method that the password has been changed.
Function password​_validators​_help​_texts Return a list of all help texts of all configured validators.
Function validate​_password Validate whether the password meets all validator requirements.
Variable password​_validators​_help​_text​_html Undocumented
Function ​_password​_validators​_help​_text​_html Return an HTML string with all help texts of all configured validators in an <ul>.
Function exceeds​_maximum​_length​_ratio Test that value is within a reasonable range of password.
Function get​_default​_password​_validators Undocumented
def get_password_validators(validator_config):

Undocumented

def password_changed(password, user=None, password_validators=None):
Inform all validators that have implemented a password_changed() method that the password has been changed.
def password_validators_help_texts(password_validators=None):
Return a list of all help texts of all configured validators.
def validate_password(password, user=None, password_validators=None):

Validate whether the password meets all validator requirements.

If the password is valid, return None. If the password is invalid, raise ValidationError with all error messages.

password_validators_help_text_html =

Undocumented

def _password_validators_help_text_html(password_validators=None):
Return an HTML string with all help texts of all configured validators in an <ul>.
def exceeds_maximum_length_ratio(password, max_similarity, value):

Test that value is within a reasonable range of password.

The following ratio calculations are based on testing SequenceMatcher like this:

for i in range(0,6):
print(10**i, SequenceMatcher(a='A', b='A'*(10**i)).quick_ratio())

which yields:

1 1.0 10 0.18181818181818182 100 0.019801980198019802 1000 0.001998001998001998 10000 0.00019998000199980003 100000 1.999980000199998e-05

This means a length_ratio of 10 should never yield a similarity higher than 0.2, for 100 this is down to 0.02 and for 1000 it is 0.002. This can be calculated via 2 / length_ratio. As a result we avoid the potentially expensive sequence matching.

@functools.lru_cache(maxsize=None)
def get_default_password_validators():

Undocumented