diff --git a/authentik/blueprints/api.py b/authentik/blueprints/api.py index 93833b935a..33578e2043 100644 --- a/authentik/blueprints/api.py +++ b/authentik/blueprints/api.py @@ -129,5 +129,5 @@ class BlueprintInstanceViewSet(UsedByMixin, ModelViewSet): def apply(self, request: Request, *args, **kwargs) -> Response: """Apply a blueprint""" blueprint = self.get_object() - apply_blueprint.send(blueprint.pk).get() + apply_blueprint.send_with_options(args=(blueprint.pk,), rel_obj=blueprint) return self.retrieve(request, *args, **kwargs) diff --git a/authentik/blueprints/v1/meta/apply_blueprint.py b/authentik/blueprints/v1/meta/apply_blueprint.py index abd593c045..de518e4838 100644 --- a/authentik/blueprints/v1/meta/apply_blueprint.py +++ b/authentik/blueprints/v1/meta/apply_blueprint.py @@ -44,7 +44,7 @@ class ApplyBlueprintMetaSerializer(PassiveSerializer): return MetaResult() LOGGER.debug("Applying blueprint from meta model", blueprint=self.blueprint_instance) - apply_blueprint(str(self.blueprint_instance.pk)) + apply_blueprint(self.blueprint_instance.pk) return MetaResult() diff --git a/authentik/blueprints/v1/tasks.py b/authentik/blueprints/v1/tasks.py index 2e7948d2b1..5258e86cfa 100644 --- a/authentik/blueprints/v1/tasks.py +++ b/authentik/blueprints/v1/tasks.py @@ -4,6 +4,7 @@ from dataclasses import asdict, dataclass, field from hashlib import sha512 from pathlib import Path from sys import platform +from uuid import UUID from dacite.core import from_dict from django.db import DatabaseError, InternalError, ProgrammingError @@ -192,7 +193,7 @@ def check_blueprint_v1_file(blueprint: BlueprintFile): @actor -def apply_blueprint(instance_pk: str): +def apply_blueprint(instance_pk: UUID): """Apply single blueprint""" self = CurrentTask.get_task() self.set_uid(str(instance_pk)) diff --git a/authentik/outposts/apps.py b/authentik/outposts/apps.py index 3974a143a0..07d0ac8696 100644 --- a/authentik/outposts/apps.py +++ b/authentik/outposts/apps.py @@ -63,29 +63,25 @@ class AuthentikOutpostConfig(ManagedAppConfig): else: Outpost.objects.filter(managed=MANAGED_OUTPOST).delete() - @ManagedAppConfig.reconcile_global - def outpost_connection_discovery(self): - from authentik.tasks.schedules.models import Schedule - - for schedule in Schedule.objects.filter( - actor_name__in=("authentik.outposts.tasks.outpost_connection_discovery",), - ): - schedule.send() - @property def tenant_schedule_specs(self) -> list[ScheduleSpec]: + from authentik.outposts.tasks import outpost_token_ensurer + return [ ScheduleSpec( - actor_name="authentik.outposts.tasks.outpost_token_ensurer", + actor_name=outpost_token_ensurer.actor_name, crontab=f"{fqdn_rand('outpost_token_ensurer')} */8 * * *", ), ] @property def global_schedule_specs(self) -> list[ScheduleSpec]: + from authentik.outposts.tasks import outpost_connection_discovery + return [ ScheduleSpec( - actor_name="authentik.outposts.tasks.outpost_connection_discovery", + actor_name=outpost_connection_discovery.actor_name, crontab=f"{fqdn_rand('outpost_connection_discovery')} */8 * * *", + run_on_startup=True, ), ]