Compare commits

...

2 Commits

Author SHA1 Message Date
Jens Langhammer
15744b18e9 handle mode file not found
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2026-01-08 19:56:08 +01:00
Jens Langhammer
558cf87ac0 blueprints: fix creating blueprint instances created in tasks timing out
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2026-01-08 18:55:47 +01:00
2 changed files with 22 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ from authentik.blueprints.v1.oci import OCI_PREFIX
from authentik.blueprints.v1.tasks import apply_blueprint, blueprints_find_dict
from authentik.core.api.used_by import UsedByMixin
from authentik.core.api.utils import JSONDictField, ModelSerializer, PassiveSerializer
from authentik.lib.utils.task import run_task
from authentik.rbac.decorators import permission_required
@@ -39,7 +40,7 @@ class BlueprintInstanceSerializer(ModelSerializer):
"""Ensure the path (if set) specified is retrievable"""
if path == "" or path.startswith(OCI_PREFIX):
return path
files: list[dict] = blueprints_find_dict.send().get_result(block=True)
files = run_task(blueprints_find_dict)
if path not in [file["path"] for file in files]:
raise ValidationError(_("Blueprint file does not exist"))
return path

View File

@@ -0,0 +1,20 @@
from functools import lru_cache
from pathlib import Path
from tempfile import gettempdir
from typing import Any
from dramatiq import Actor
@lru_cache
def current_mode():
try:
return (Path(gettempdir()) / "authentik-mode").read_text().strip()
except OSError:
return "server"
def run_task[T: Any](t: Actor[(str), T], *args, **kwargs) -> T:
if current_mode() == "worker":
return callable(*args, **kwargs)
return callable().send(*args, **kwargs).get_result(block=True)