providers proxy: migrate tasks

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2025-03-31 14:34:54 +02:00
parent b756965511
commit f5f0cef275
3 changed files with 9 additions and 7 deletions

View File

@ -14,10 +14,10 @@ def logout_proxy_revoke_direct(sender: type[User], request: HttpRequest, **_):
"""Catch logout by direct logout and forward to proxy providers"""
if not request.session or not request.session.session_key:
return
proxy_on_logout.delay(request.session.session_key)
proxy_on_logout.send(request.session.session_key)
@receiver(pre_delete, sender=AuthenticatedSession)
def logout_proxy_revoke(sender: type[AuthenticatedSession], instance: AuthenticatedSession, **_):
"""Catch logout by expiring sessions being deleted"""
proxy_on_logout.delay(instance.session_key)
proxy_on_logout.send(instance.session_key)

View File

@ -3,15 +3,15 @@
from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer
from django.db import DatabaseError, InternalError, ProgrammingError
from dramatiq.actor import actor
from authentik.outposts.consumer import OUTPOST_GROUP
from authentik.outposts.models import Outpost, OutpostType
from authentik.providers.oauth2.id_token import hash_session_key
from authentik.providers.proxy.models import ProxyProvider
from authentik.root.celery import CELERY_APP
@CELERY_APP.task(
@actor(
throws=(DatabaseError, ProgrammingError, InternalError),
)
def proxy_set_defaults():
@ -21,7 +21,7 @@ def proxy_set_defaults():
provider.save()
@CELERY_APP.task()
@actor
def proxy_on_logout(session_id: str):
"""Update outpost instances connected to a single outpost"""
layer = get_channel_layer()

View File

@ -91,6 +91,7 @@ def _get_startup_tasks_default_tenant() -> list[Callable]:
"""Get all tasks to be run on startup for the default tenant"""
# from authentik.outposts.tasks import outpost_connection_discovery
# TODO: figure out what to do with this
return [
# outpost_connection_discovery,
]
@ -99,11 +100,12 @@ def _get_startup_tasks_default_tenant() -> list[Callable]:
def _get_startup_tasks_all_tenants() -> list[Callable]:
"""Get all tasks to be run on startup for all tenants"""
# from authentik.admin.tasks import clear_update_notifications
from authentik.providers.proxy.tasks import proxy_set_defaults
# from authentik.providers.proxy.tasks import proxy_set_defaults
# TODO: figure out what to do with this
return [
# clear_update_notifications,
proxy_set_defaults,
# proxy_set_defaults,
]