Beispiel #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)
Beispiel #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)
Beispiel #3
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 crack 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)
Beispiel #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 crack 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)