CommonPasswordValidator
Validate that the password is not a common password.
Attributes
| Attribute | Type | Description |
|---|---|---|
| passwords | set | A set of lowercased, stripped strings representing common passwords loaded from the specified file path for membership testing during validation. |
Constructor
Signature
def CommonPasswordValidator(
password_list_path: str|Path = DEFAULT_PASSWORD_LIST_PATH
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| password_list_path | `str | Path` = DEFAULT_PASSWORD_LIST_PATH |
Signature
def CommonPasswordValidator(
password_list_path: str | Path = DEFAULT_PASSWORD_LIST_PATH
)
Parameters
| Name | Type | Description |
|---|---|---|
| password_list_path | `str | Path` = DEFAULT_PASSWORD_LIST_PATH |
Methods
DEFAULT_PASSWORD_LIST_PATH()
@classmethod
def DEFAULT_PASSWORD_LIST_PATH() - > Path
Returns the absolute file path to the default gzipped text file containing the list of common passwords.
Returns
| Type | Description |
|---|---|
Path | The resolved Path object pointing to 'common-passwords.txt.gz' within the validator's directory |
validate()
@classmethod
def validate(
password: string,
user: object = None
) - > None
Checks if the provided password exists in the forbidden password list and raises a ValidationError if a match is found.
Parameters
| Name | Type | Description |
|---|---|---|
| password | string | The raw password string to be checked against the common password list |
| user | object = None | The user instance associated with the password, though not used in this specific validation logic |
Returns
| Type | Description |
|---|---|
None | Nothing is returned if the password passes validation |
get_error_message()
@classmethod
def get_error_message() - > string
Provides the localized error message displayed to the user when a password is rejected for being too common.
Returns
| Type | Description |
|---|---|
string | A translated string stating that the password is too common |
get_help_text()
@classmethod
def get_help_text() - > string
Provides the localized instructional text used to inform users about password complexity requirements.
Returns
| Type | Description |
|---|---|
string | A translated string explaining that commonly used passwords are not permitted |