From 7b0d8f89912a0ed54af0e32c3befffcf698c1c75 Mon Sep 17 00:00:00 2001 From: Jens L Date: Thu, 27 Apr 2023 15:03:50 +0300 Subject: [PATCH] providers/scim: ensure scim group member isn't None (#5391) Signed-off-by: Jens Langhammer --- authentik/lib/sentry.py | 3 +++ authentik/providers/scim/clients/group.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/authentik/lib/sentry.py b/authentik/lib/sentry.py index 70d7246ca..4f6f5c45a 100644 --- a/authentik/lib/sentry.py +++ b/authentik/lib/sentry.py @@ -15,6 +15,7 @@ from h11 import LocalProtocolError from ldap3.core.exceptions import LDAPException from redis.exceptions import ConnectionError as RedisConnectionError from redis.exceptions import RedisError, ResponseError +from requests_mock.exceptions import NoMockAddress from rest_framework.exceptions import APIException from sentry_sdk import HttpTransport from sentry_sdk import init as sentry_sdk_init @@ -140,6 +141,8 @@ def before_send(event: dict, hint: dict) -> Optional[dict]: Http404, # AsyncIO CancelledError, + # Requests + NoMockAddress, ) exc_value = None if "exc_info" in hint: diff --git a/authentik/providers/scim/clients/group.py b/authentik/providers/scim/clients/group.py index cd974ef4c..63eb74af2 100644 --- a/authentik/providers/scim/clients/group.py +++ b/authentik/providers/scim/clients/group.py @@ -81,12 +81,15 @@ class SCIMGroupClient(SCIMClient[Group, SCIMGroupSchema]): users = list(obj.users.order_by("id").values_list("id", flat=True)) connections = SCIMUser.objects.filter(provider=self.provider, user__pk__in=users) + members = [] for user in connections: - scim_group.members.append( + members.append( GroupMember( value=user.id, ) ) + if members: + scim_group.members = members return scim_group def _create(self, group: Group):