def synchronize_groups_with_login_method(): """For each login_method, if possible, synchronize groups in a bulk fashion (i.e. when fetch_all_users_groups_membership is implemented in the external_authentication class). Otherwise, for each user that belong to at least one external group for a given login_method, ask, if possible, for his group memberships and merge them. """ from invenio.access_control_config import CFG_EXTERNAL_AUTHENTICATION for login_method, authorizer in CFG_EXTERNAL_AUTHENTICATION.items(): if authorizer: try: usersgroups = authorizer.fetch_all_users_groups_membership() synchronize_all_external_groups(usersgroups, login_method) except (NotImplementedError, NameError): users = db.get_all_users_with_groups_with_login_method( login_method) for email, uid in users.items(): try: groups = authorizer.fetch_user_groups_membership(email) synchronize_external_groups(uid, groups, login_method) except (NotImplementedError, NameError): pass
def synchronize_groups_with_login_method(): """For each login_method, if possible, synchronize groups in a bulk fashion (i.e. when fetch_all_users_groups_membership is implemented in the external_authentication class). Otherwise, for each user that belong to at least one external group for a given login_method, ask, if possible, for his group memberships and merge them. """ from invenio.access_control_config import CFG_EXTERNAL_AUTHENTICATION for login_method, authorizer in CFG_EXTERNAL_AUTHENTICATION.items(): if authorizer: try: usersgroups = authorizer.fetch_all_users_groups_membership() synchronize_all_external_groups(usersgroups, login_method) except (NotImplementedError, NameError): users = db.get_all_users_with_groups_with_login_method(login_method) for email, uid in users.items(): try: groups = authorizer.fetch_user_groups_membership(email) synchronize_external_groups(uid, groups, login_method) except (NotImplementedError, NameError): pass