From c0944a6027b32afe187b15b5e9eb0d139ed5f774 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 10 May 2023 11:11:28 +0200 Subject: [PATCH] re-raise ResourceMissing in group update to trigger recreation Signed-off-by: Jens Langhammer --- authentik/providers/scim/clients/group.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/authentik/providers/scim/clients/group.py b/authentik/providers/scim/clients/group.py index 7b2592a390b4..b0222590de5d 100644 --- a/authentik/providers/scim/clients/group.py +++ b/authentik/providers/scim/clients/group.py @@ -117,20 +117,23 @@ def _update(self, group: Group, connection: SCIMGroup): exclude_unset=True, ), ) + except ResourceMissing: + # Resource missing is handled by self.write, which will re-create the group + raise except SCIMRequestException: # Some providers don't support PUT on groups, so this is mainly a fix for the initial # sync, send patch add requests for all the users the group currently has users = list(group.users.order_by("id").values_list("id", flat=True)) self._patch_add_users(group, users) # Also update the group name - self._patch( + return self._patch( scim_group.id, PatchOperation( op=PatchOp.replace, value={ "id": connection.id, "displayName": group.name, - } + }, ), )