Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion user_sync/connector/directory_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, caller_options):
builder.set_string_value('domain_column_name', 'domain')
builder.set_string_value('identity_type_column_name', 'type')
builder.set_string_value('user_identity_type', None)
builder.set_string_value('logger_name', 'connector.' + CSVDirectoryConnector.name)
builder.set_string_value('logger_name', CSVDirectoryConnector.name)
builder.require_string_value('file_path')
options = builder.get_options()

Expand Down
2 changes: 1 addition & 1 deletion user_sync/connector/directory_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, caller_options):
builder.set_string_value('user_domain_format', None)
builder.set_string_value('user_identity_type', None)
builder.set_int_value('search_page_size', 200)
builder.set_string_value('logger_name', 'connector.' + LDAPDirectoryConnector.name)
builder.set_string_value('logger_name', LDAPDirectoryConnector.name)
host = builder.require_string_value('host')
username = builder.require_string_value('username')
builder.require_string_value('base_dn')
Expand Down
28 changes: 16 additions & 12 deletions user_sync/connector/umapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

import helper
import user_sync.config
import user_sync.error
import user_sync.helper
import user_sync.identity_type
from user_sync.error import AssertionException
from user_sync.version import __version__ as APP_VERSION

try:
Expand Down Expand Up @@ -84,16 +84,20 @@ def __init__(self, name, caller_options):
"client_secret": enterprise_options['client_secret'],
"private_key_file": private_key_file_path
}
self.connection = connection = umapi_client.Connection(
org_id=org_id,
auth_dict=auth_dict,
ims_host=ims_host,
ims_endpoint_jwt=server_options['ims_endpoint_jwt'],
user_management_endpoint=um_endpoint,
test_mode=options['test_mode'],
user_agent="user-sync/" + APP_VERSION,
logger=self.logger,
)
try:
self.connection = connection = umapi_client.Connection(
org_id=org_id,
auth_dict=auth_dict,
ims_host=ims_host,
ims_endpoint_jwt=server_options['ims_endpoint_jwt'],
user_management_endpoint=um_endpoint,
test_mode=options['test_mode'],
user_agent="user-sync/" + APP_VERSION,
logger=self.logger,
)
except Exception as e:
raise AssertionException("UMAPI connection to org id '%s' failed: %s" % (org_id, e))

logger.debug('API initialized on: %s', um_endpoint)

self.action_manager = ActionManager(connection, org_id, logger)
Expand Down Expand Up @@ -184,7 +188,7 @@ def add_user(self, attributes):
email = self.email if self.email else self.username
if not email:
errorMessage = "ERROR: you must specify an email with an Adobe ID"
raise user_sync.error.AssertionException(errorMessage)
raise AssertionException(errorMessage)
params = self.convert_user_attributes_to_params({'email': email})
else:
params = self.convert_user_attributes_to_params(attributes)
Expand Down
2 changes: 1 addition & 1 deletion user_sync/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def iter_csv_rows(file_path, delimiter = None, recognized_column_names = None, l
if (recognized_column_names != None):
unrecognized_column_names = [column_name for column_name in reader.fieldnames if column_name not in recognized_column_names]
if (len(unrecognized_column_names) > 0 and logger != None):
logger.warn("Unrecognized column names: %s", unrecognized_column_names)
logger.warn("In file '%s': unrecognized column names: %s", file_path, unrecognized_column_names)

for row in reader:
yield row
Expand Down
27 changes: 10 additions & 17 deletions user_sync/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ def update_umapi_users_for_connector(self, umapi_info, umapi_connector):
options = self.options
update_user_info = options['update_user_info']
manage_groups = self.will_manage_groups()
exclude_strays = self.options['exclude_strays']
will_process_strays = self.will_process_strays

# prepare the strays map if we are going to be processing them
Expand All @@ -688,12 +689,6 @@ def update_umapi_users_for_connector(self, umapi_info, umapi_connector):
# there are certain operations we only do in the primary umapi
in_primary_org = umapi_info.get_name() == PRIMARY_UMAPI_NAME

# we only log certain users if they are relevant to our processing.
log_excluded_users = update_user_info or manage_groups
log_stray_users = will_process_strays
log_matching_users = update_user_info or manage_groups


# Walk all the adobe users, getting their group data, matching them with directory users,
# and adjusting their attribute and group data accordingly.
for umapi_user in umapi_connector.iter_users():
Expand All @@ -712,24 +707,25 @@ def update_umapi_users_for_connector(self, umapi_info, umapi_connector):
desired_groups = user_to_group_map.pop(user_key, None) or set()

# check for excluded users
if self.is_umapi_user_excluded(in_primary_org, user_key, current_groups, log_excluded_users):
if self.is_umapi_user_excluded(in_primary_org, user_key, current_groups):
continue

directory_user = filtered_directory_user_by_user_key.get(user_key)
if directory_user is None:
# There's no selected directory user matching this adobe user
# so we mark this adobe user as a stray, and we mark him
# for removal from any mapped groups.
if log_stray_users:
if exclude_strays:
self.logger.debug("Excluding Adobe-only user: %s", user_key)
elif will_process_strays:
self.logger.debug("Found Adobe-only user: %s", user_key)
if will_process_strays:
self.add_stray(umapi_info.get_name(), user_key,
None if not manage_groups else current_groups & umapi_info.get_mapped_groups())
else:
# There is a selected directory user who matches this adobe user,
# so mark any changed umapi attributes,
# and mark him for addition and removal of the appropriate mapped groups
if log_matching_users:
if update_user_info or manage_groups:
self.logger.debug("Adobe user matched on customer side: %s", user_key)
if update_user_info and in_primary_org:
attribute_differences = self.get_user_attribute_difference(directory_user, umapi_user)
Expand All @@ -745,24 +741,21 @@ def update_umapi_users_for_connector(self, umapi_info, umapi_connector):
umapi_info.set_umapi_users_loaded()
return user_to_group_map

def is_umapi_user_excluded(self, in_primary_org, user_key, current_groups, do_logging):
def is_umapi_user_excluded(self, in_primary_org, user_key, current_groups):
if in_primary_org:
# in the primary umapi, we actually check the exclusion conditions
identity_type, username, domain = self.parse_user_key(user_key)
if identity_type in self.exclude_identity_types:
if do_logging:
self.logger.debug("Excluding adobe user (due to type): %s", user_key)
self.logger.debug("Excluding adobe user (due to type): %s", user_key)
self.excluded_user_count += 1
return True
if len(current_groups & self.exclude_groups) > 0:
if do_logging:
self.logger.debug("Excluding adobe user (due to group): %s", user_key)
self.logger.debug("Excluding adobe user (due to group): %s", user_key)
self.excluded_user_count += 1
return True
for re in self.exclude_users:
if re.match(username):
if do_logging:
self.logger.debug("Excluding adobe user (due to name): %s", user_key)
self.logger.debug("Excluding adobe user (due to name): %s", user_key)
self.excluded_user_count += 1
return True
self.included_user_keys.add(user_key)
Expand Down