Esempio n. 1
0
def outbound_user_filter(sawtooth_user, provider):
    """Takes in a user dict from queue_outbound and formats it to a providers specs.
    :param: user > dict > a dictionary representing a user
    :param: provider > str > inbound provider type (azure, ldap)
    """
    if provider != "azure" and provider != "ldap":
        raise TypeError("Provider must be specified with a valid option.")
    user = {}
    for key, value in USER_TRANSFORM.items():
        if key in sawtooth_user:
            user[value[provider]] = sawtooth_user[key]
    return user
Esempio n. 2
0
def inbound_user_filter(user, provider):
    """Takes in a user dict from a provider and standardizes the dict and returns it.
    :param: user > dict > a dictionary representing a user
    :param: provider > str > inbound provider type (azure, ldap)
    """
    if provider != "azure" and provider != "ldap":
        raise TypeError("Provider must be specified with a valid option.")
    clean_user = {}
    for key, value in USER_TRANSFORM.items():
        if value[provider] in user:
            clean_user[key] = user[value[provider]]
        else:
            clean_user[key] = None
    return clean_user
def inbound_user_filter(user, provider):
    """Takes in a user dict from a provider,standardizes and then returns it.
    :param: user > dict > dictionary with user payload from provider
    :param: provider > str > provider
    """
    if provider not in ("azure", "ldap"):
        raise TypeError("Provider must be specified with a valid option.")
    standardized_user = {}
    for key, value in USER_TRANSFORM.items():
        if value[provider] in user:
            value = inbound_value_filter(user[value[provider]])
            standardized_user[key] = value
    if "email" not in standardized_user and "user_principal_name" in standardized_user:
        standardized_user["email"] = standardized_user["user_principal_name"]
    return standardized_user
Esempio n. 4
0
def inbound_user_filter(user, provider):
    """Takes in a user dict from a provider and standardizes the dict and returns it.
    :param: user > dict > a dictionary representing a user
    :param: provider > str > inbound provider type (azure, ldap)
    """
    if provider not in ("azure", "ldap"):
        raise TypeError("Provider must be specified with a valid option.")
    clean_user = {}
    for key, alias in USER_TRANSFORM.items():
        if alias[provider] in user:
            value = inbound_value_filter(user[alias[provider]])
            if value:
                clean_user[key] = value
    for key, aliases in STANDARD_USER_TRANSFORM.items():
        if key not in clean_user:
            for alias in aliases:
                if alias in user:
                    value = inbound_value_filter(user[alias])
                    if value:
                        clean_user[key] = value
                        break
    return clean_user
Esempio n. 5
0
def inbound_user_filter(entry, provider):
    """Takes in a user dict from a provider and standardizes the dict and returns it.
    :param: user > dict > a dictionary representing a user
    :param: provider > str > inbound provider type (azure, ldap)
    """
    if provider not in ("azure", "ldap"):
        raise TypeError("Provider must be specified with a valid option.")
    standard_entry = {}
    for key, alias in USER_TRANSFORM.items():
        if alias[provider] in entry:
            value = inbound_value_filter(entry[alias[provider]])
            if value:
                standard_entry[key] = value
    if "email" not in standard_entry and "user_principal_name" in standard_entry:
        standard_entry["email"] = standard_entry["user_principal_name"]
    for key, aliases in STANDARD_USER_TRANSFORM.items():
        if key not in standard_entry:
            for alias in aliases:
                if alias in entry:
                    value = inbound_value_filter(entry[alias])
                    if value:
                        standard_entry[key] = value
                        break
    return standard_entry