Skip to content

Commit a233fee

Browse files
lib/sync/outgoing: check if there is a provider before creating tasks (cherry-pick #18394 to version-2025.10) (#18397)
lib/sync/outgoing: check if there is a provider before creating tasks (#18394) Signed-off-by: Marc 'risson' Schmitt <[email protected]> Co-authored-by: Marc 'risson' Schmitt <[email protected]>
1 parent bc9215a commit a233fee

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

authentik/enterprise/providers/ssf/tasks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def send_ssf_events(
4242
for stream in Stream.objects.filter(**stream_filter):
4343
event_data = stream.prepare_event_payload(event_type, data, **extra_data)
4444
events_data[stream.uuid] = event_data
45+
if not events_data:
46+
return
4547
ssf_events_dispatch.send(events_data)
4648

4749

authentik/lib/sync/outgoing/signals.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def model_post_save(
2828
# This primarily happens during user login
2929
if sender == User and update_fields == {"last_login"}:
3030
return
31+
if not provider_type.objects.exists():
32+
return
3133
task_sync_direct_dispatch.send(
3234
class_to_path(instance.__class__),
3335
instance.pk,
@@ -39,6 +41,8 @@ def model_post_save(
3941

4042
def model_pre_delete(sender: type[Model], instance: User | Group, **_):
4143
"""Pre-delete handler"""
44+
if not provider_type.objects.exists():
45+
return
4246
task_sync_direct_dispatch.send(
4347
class_to_path(instance.__class__),
4448
instance.pk,
@@ -54,6 +58,8 @@ def model_m2m_changed(
5458
"""Sync group membership"""
5559
if action not in ["post_add", "post_remove"]:
5660
return
61+
if not provider_type.objects.exists():
62+
return
5763
task_sync_m2m_dispatch.send(instance.pk, action, list(pk_set), reverse)
5864

5965
m2m_changed.connect(model_m2m_changed, User.ak_groups.through, dispatch_uid=uid, weak=False)

authentik/providers/oauth2/signals.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def user_session_deleted_oauth_backchannel_logout_and_tokens_removal(
109109
"""Revoke tokens upon user logout"""
110110
LOGGER.debug("Sending back-channel logout notifications signal!", session=instance)
111111

112-
access_tokens = AccessToken.objects.filter(
112+
access_tokens = AccessToken.objects.select_related("provider").filter(
113113
user=instance.user,
114114
session__session__session_key=instance.session.session_key,
115115
)
@@ -128,7 +128,8 @@ def user_session_deleted_oauth_backchannel_logout_and_tokens_removal(
128128
and token.provider.logout_method == OAuth2LogoutMethod.BACKCHANNEL
129129
]
130130

131-
backchannel_logout_notification_dispatch.send(revocations=backchannel_tokens)
131+
if backchannel_tokens:
132+
backchannel_logout_notification_dispatch.send(revocations=backchannel_tokens)
132133

133134
access_tokens.delete()
134135

0 commit comments

Comments
 (0)