diff --git a/groups.py b/groups.py index f412f60fc..162285179 100644 --- a/groups.py +++ b/groups.py @@ -1060,8 +1060,9 @@ def group_create(ctx, group_name, category, subcategory, schema_id, expiration_d return api.Error('sram_error', message) else: co_identifier = response_sram['identifier'] + short_name = response_sram['short_name'] - if not sram.sram_connect_service_collaboration(ctx, group_name): + if not sram.sram_connect_service_collaboration(ctx, short_name): return api.Error('sram_error', 'Something went wrong connecting service to group "{}" in SRAM'.format(group_name)) response = ctx.uuGroupAdd(group_name, category, subcategory, schema_id, expiration_date, description, data_classification, co_identifier, '', '')['arguments'] @@ -1337,9 +1338,10 @@ def rule_group_sram_sync(ctx): break else: co_identifier = response_sram['identifier'] + short_name = response_sram['short_name'] avu.associate_to_group(ctx, group_name, "co_identifier", co_identifier) - if not sram.sram_connect_service_collaboration(ctx, group_name): + if not sram.sram_connect_service_collaboration(ctx, short_name): log.write(ctx, "Something went wrong connecting service to group {} in SRAM".format(group_name)) break diff --git a/requirements.txt b/requirements.txt index 2b395255d..adf159c74 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,6 +20,5 @@ pysqlcipher3==1.0.4 execnet==1.9.0 deepdiff==3.3.0 persist-queue==0.8.1 -pyblake2==1.1.2 redis==3.5.3 psutil==5.9.6 diff --git a/sram.py b/sram.py index cf08fe484..bbf4813de 100644 --- a/sram.py +++ b/sram.py @@ -36,9 +36,6 @@ def sram_post_collaboration(ctx, group_name, description, expiration_date): epoch = datetime.datetime.utcfromtimestamp(0) epoch_date = int((date - epoch).total_seconds()) - # Create unique short name of group - short_name = group.unique_short_name(ctx, group_name) - disable_join_requests = True if config.sram_flow == 'join_request': disable_join_requests = False @@ -46,7 +43,6 @@ def sram_post_collaboration(ctx, group_name, description, expiration_date): # Build SRAM payload. payload = { "name": 'yoda-' + group_name, - "short_name": short_name, "description": description, "disable_join_requests": disable_join_requests, "disclose_member_information": True, @@ -190,20 +186,17 @@ def sram_put_collaboration_invitation(ctx, group_name, username, co_identifier): return response.status_code == 201 -def sram_connect_service_collaboration(ctx, group_name): +def sram_connect_service_collaboration(ctx, short_name): """Connect a service to an existing SRAM collaboration. :param ctx: Combined type of a ctx and rei struct - :param group_name: Name of the group + :param short_name: Short name of the group collaboration :returns: Boolean indicating if connecting a service to an existing collaboration succeeded """ url = "{}/api/collaborations_services/v1/connect_collaboration_service".format(config.sram_rest_api_url) headers = {'Content-Type': 'application/json', 'charset': 'UTF-8', 'Authorization': 'bearer ' + config.sram_api_key} - # Create unique short name of group - short_name = group.unique_short_name(ctx, group_name) - # Build SRAM payload. payload = { "short_name": short_name, diff --git a/util/group.py b/util/group.py index d00ebc27c..b56b32067 100644 --- a/util/group.py +++ b/util/group.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- """Utility / convenience functions for querying user info.""" -__copyright__ = 'Copyright (c) 2019-2021, Utrecht University' +__copyright__ = 'Copyright (c) 2019-2023, Utrecht University' __license__ = 'GPLv3, see LICENSE' import genquery -from pyblake2 import blake2b import user @@ -58,21 +57,3 @@ def get_category(ctx, grp): ret = ctx.uuGroupGetCategory(grp, '', '') x = ret['arguments'][1] return None if x == '' else x - - -def unique_short_name(ctx, group_name): - """Create unique short name for group in SRAM. - - :param ctx: Combined type of a callback and rei struct - :param group_name: Group name - - :returns: Blake2b hash of zone and group name prefixed with y - """ - zone = user.zone(ctx) - concat_string = zone + group_name - - # Create hash of 16 characters - short_name = blake2b(digest_size=7) - short_name.update(concat_string.encode()) - - return "y_{}".format(short_name.hexdigest())