Пример #1
0
def create(id, password):
    """Create a new user in the Bakula IAM

    Args:
        id: The new user's ID
        password: The new user's password

    Returns:
        True if created
    """
    try:
        User.get(User.id == id)
        return False
    except User.DoesNotExist:
        User.create(id=id, password=bcrypt.hashpw(password, bcrypt.gensalt()))
        return True
Пример #2
0
def create(id, password):
    """Create a new user in the Bakula IAM

    Args:
        id: The new user's ID
        password: The new user's password

    Returns:
        True if created
    """
    try:
        User.get(User.id == id)
        return False
    except User.DoesNotExist:
        User.create(id=id, password=bcrypt.hashpw(password, bcrypt.gensalt()))
        return True
Пример #3
0
def authenticate(id, password):
    """Authenticate the user against the underlying IAM

    Args:
        id: The ID of the user
        password: The password for the user to verify

    Returns:
        a boolean if the user is authenticated to use Bakula
    """
    try:
        user = User.get(User.id == id)
        # Check that the incoming (unhashed) password matches the stored
        # (hashed) password. The hashpw method takes the hashed password,
        # uses the stored salt, and hashes the incoming password. Then we
        # check the result against the stored (hashed) password.
        if bcrypt.hashpw(password, user.password) == user.password:
            return True
        return False
    except User.DoesNotExist:
        return False
Пример #4
0
def authenticate(id, password):
    """Authenticate the user against the underlying IAM

    Args:
        id: The ID of the user
        password: The password for the user to verify

    Returns:
        a boolean if the user is authenticated to use Bakula
    """
    try:
        user = User.get(User.id == id)
        # Check that the incoming (unhashed) password matches the stored
        # (hashed) password. The hashpw method takes the hashed password,
        # uses the stored salt, and hashes the incoming password. Then we
        # check the result against the stored (hashed) password.
        if bcrypt.hashpw(password, user.password) == user.password:
            return True
        return False
    except User.DoesNotExist:
        return False