How to use the ocflib.account.validators.validate_password function in ocflib

To help you get started, we’ve selected a few ocflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ocf / ocflib / ocflib / account / creation.py View on Github external
def validate_password(username, password):
    try:
        validators.validate_password(username, password)
    except ValueError as ex:
        raise ValidationError(str(ex))
github ocf / ircbot / create / approve.py View on Github external
                validator=lambda pwd: validate_password(
                    account['user_name'], pwd),
            )
github ocf / ocfweb / ocfweb / account / vhost_mail.py View on Github external
def _get_password(request: HttpRequest, addr_name: Optional[str]) -> Any:
    # If addr_name is None, then this is a wildcard address, and those can't
    # have passwords.
    if addr_name is None:
        return REMOVE_PASSWORD

    password = request.POST.get('password')
    if password is not None:
        password = password.strip()
        if not password:
            return REMOVE_PASSWORD
        try:
            validate_password(addr_name, password, strength_check=True)
        except ValueError as ex:
            _error(request, ex.args[0])
        else:
            return crypt_password(password)
github ocf / ocflib / ocflib / account / manage.py View on Github external
def change_password_with_keytab(username, password, keytab, principal, comment=None):
    """Change a user's Kerberos password using a keytab, subject to username
    and password validation.

    :param comment: comment to include in notification email
    """
    validators.validate_username(username, check_exists=True)
    validators.validate_password(username, password)

    # try changing using kadmin pexpect
    cmd = '{kadmin_path} -K {keytab} -p {principal} cpw {username}'.format(
        kadmin_path=shlex.quote(KADMIN_PATH),
        keytab=shlex.quote(keytab),
        principal=shlex.quote(principal),
        username=shlex.quote(username))

    child = pexpect.spawn(cmd, timeout=10)

    child.expect("{}@OCF.BERKELEY.EDU's Password:".format(username))
    child.sendline(password)
    child.expect("Verify password - {}@OCF.BERKELEY.EDU's Password:"
                 .format(username))
    child.sendline(password)
github ocf / ocflib / ocflib / account / manage.py View on Github external
def change_password_with_staffer(username, password, principal,
                                 admin_password, comment=None):
    """Change a user's Kerberos password using kadmin and a password, subject
    to username and password validation.

    :param comment: comment to include in notification email
    """
    validators.validate_username(username)
    validators.validate_password(username, password)

    # try changing using kadmin pexpect
    cmd = '{kadmin_path} -p {principal} cpw {username}'.format(
        kadmin_path=shlex.quote(KADMIN_PATH),
        principal=shlex.quote(principal),
        username=shlex.quote(username))

    child = pexpect.spawn(cmd, timeout=10)

    child.expect("{}@OCF.BERKELEY.EDU's Password:".format(username))
    child.sendline(password)
    child.expect("Verify password - {}@OCF.BERKELEY.EDU's Password:"
                 .format(username))
    child.sendline(password)

    # now give admin principal password