Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_identities(organization, identity_ids):
identity_client = get_identity_client(organization)
return identity_client.read_identities(identity_ids=identity_ids)
def resolve_identity(identity_filter, organization):
"""Takes an identity name, email, alias, or id, and returns the identity.
"""
if identity_filter is None:
return None
if identity_filter.lower() == ME:
return get_current_identity(organization)
identity_client = get_identity_client(organization)
if identity_filter.find(' ') > 0 or identity_filter.find('@') > 0:
identities = identity_client.read_identities(search_filter='General',
filter_value=identity_filter)
if identities is None or not identities:
identities = identity_client.read_identities(search_filter='DirectoryAlias',
filter_value=identity_filter)
else:
identities = identity_client.read_identities(search_filter='DirectoryAlias',
filter_value=identity_filter)
if identities is None or not identities:
identities = identity_client.read_identities(search_filter='General',
filter_value=identity_filter)
if not identities:
raise CLIError('Could not resolve identity: ' + identity_filter)
if len(identities) > 1:
# prefer users with same domain
def get_identity_descriptor_from_subject_descriptor(subject_descriptor, organization):
identity_client = get_identity_client(organization)
identities = identity_client.read_identities(subject_descriptors=subject_descriptor)
if identities:
return identities[0].descriptor
return subject_descriptor