Skip to content

Commit

Permalink
re-raise ResourceMissing in group update to trigger recreation
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed May 10, 2023
1 parent d6bcc02 commit c0944a6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions authentik/providers/scim/clients/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 122 in authentik/providers/scim/clients/group.py

View check run for this annotation

Codecov / codecov/patch

authentik/providers/scim/clients/group.py#L122

Added line #L122 was not covered by tests
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)

Check warning on line 127 in authentik/providers/scim/clients/group.py

View check run for this annotation

Codecov / codecov/patch

authentik/providers/scim/clients/group.py#L127

Added line #L127 was not covered by tests
# Also update the group name
self._patch(
return self._patch(

Check warning on line 129 in authentik/providers/scim/clients/group.py

View check run for this annotation

Codecov / codecov/patch

authentik/providers/scim/clients/group.py#L129

Added line #L129 was not covered by tests
scim_group.id,
PatchOperation(
op=PatchOp.replace,
value={
"id": connection.id,
"displayName": group.name,
}
},
),
)

Expand Down

0 comments on commit c0944a6

Please sign in to comment.