Skip to content

Commit

Permalink
providers/scim: clamp batch size for patch requests (#11797)
Browse files Browse the repository at this point in the history
* providers/scim: clamp batch size for patch requests

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* sanity check for empty patch request instead

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu authored Oct 24, 2024
1 parent de9fc5d commit 7f0c443
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions authentik/providers/scim/clients/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def _patch_chunked(
chunk_size = self._config.bulk.maxOperations
if chunk_size < 1:
chunk_size = len(ops)
if len(ops) < 1:
return
for chunk in batched(ops, chunk_size):
req = PatchRequest(Operations=list(chunk))
self._request(
Expand Down Expand Up @@ -244,6 +246,9 @@ def patch_compare_users(self, group: Group):
for user in users_should:
if len([x for x in current_group.members if x.value == user]) < 1:
users_to_add.append(user)
# Only send request if we need to make changes
if len(users_to_add) < 1 and len(users_to_remove) < 1:
return
return self._patch_chunked(
scim_group.scim_id,
*[
Expand Down

0 comments on commit 7f0c443

Please sign in to comment.