Exemple #1
0
def assert_strong_password(username, password, old_password=None):
    """Raises ValueError if the password isn't strong.

    Returns the password otherwise."""
    if username is not None and username in password:
        raise ValueError("Password contains username")

    return _assert_password(password, old_password)
Exemple #2
0
def assert_strong_password(username, password, old_password=None):
    """Raises ValueError if the password isn't strong.

    Returns the password otherwise."""
    if username is not None and username in password:
        raise ValueError("Password contains username")

    return _assert_password(password, old_password)
Exemple #3
0
def assert_strong_password(username, password, old_password=None):
    """Raises ValueError if the password isn't strong.

    Returns the password otherwise."""

    # test the length
    try:
        minlength = settings.MIN_PASSWORD_LENGTH
    except AttributeError:
        minlength = 12
    if len(password) < minlength:
        raise ValueError(
            "Password must be at least %s characters long" % minlength)

    if username is not None and username in password:
        raise ValueError("Password contains username")

    return _assert_password(password, old_password)
Exemple #4
0
def assert_password_simple(password, old=None):
    if old and password == old:
        raise ValueError("Old and new passwords are the same.")
    elif len(password) < 6:
        raise ValueError("Password is less than six characters.")
    return password


try:
    from cracklib import VeryFascistCheck as _assert_password

    # Some configuration errors are only apparent when cracklib
    # tests a password for the first time, so test a strong password to
    # verify that cracklib is working as intended.
    _assert_password("thaeliez4niore0U")
except ImportError:
    _assert_password = assert_password_simple
except (OSError, ValueError) as e:
    LOG.warning("Cracklib misconfigured: %s", str(e))
    _assert_password = assert_password_simple


def assert_strong_password(username, password, old_password=None):
    """Raises ValueError if the password isn't strong.

    Returns the password otherwise."""
    if username is not None and username in password:
        raise ValueError("Password contains username")

    return _assert_password(password, old_password)
Exemple #5
0

def assert_password_simple(password, old=None):
    if old and password == old:
        raise ValueError('Old and new passwords are the same.')
    elif len(password) < 6:
        raise ValueError('Password is less than six characters.')
    return password


try:
    from cracklib import VeryFascistCheck as _assert_password
    # Some configuration errors are only apparent when cracklib
    # tests a password for the first time, so test a strong password to
    # verify that cracklib is working as intended.
    _assert_password('thaeliez4niore0U')
except ImportError:
    _assert_password = assert_password_simple
except (OSError, ValueError) as e:
    LOG.warning("Cracklib misconfigured: %s", str(e))
    _assert_password = assert_password_simple


def assert_strong_password(username, password, old_password=None):
    """Raises ValueError if the password isn't strong.

    Returns the password otherwise."""
    if username is not None and username in password:
        raise ValueError("Password contains username")

    return _assert_password(password, old_password)