From 411ef239f63e4d3beacd8297d4be54b29fb30127 Mon Sep 17 00:00:00 2001 From: Jens L Date: Sun, 21 May 2023 15:29:55 +0200 Subject: [PATCH] blueprints: fix check for file path not being run on worker (#5703) --- authentik/blueprints/api.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/authentik/blueprints/api.py b/authentik/blueprints/api.py index 8f8b7f06b..e22bd18e1 100644 --- a/authentik/blueprints/api.py +++ b/authentik/blueprints/api.py @@ -11,7 +11,7 @@ from rest_framework.serializers import ListSerializer, ModelSerializer from rest_framework.viewsets import ModelViewSet from authentik.api.decorators import permission_required -from authentik.blueprints.models import BlueprintInstance, BlueprintRetrievalFailed +from authentik.blueprints.models import BlueprintInstance from authentik.blueprints.v1.importer import Importer from authentik.blueprints.v1.tasks import apply_blueprint, blueprints_find_dict from authentik.core.api.used_by import UsedByMixin @@ -35,11 +35,12 @@ class BlueprintInstanceSerializer(ModelSerializer): """Info about a single blueprint instance file""" def validate_path(self, path: str) -> str: - """Ensure the path specified is retrievable""" - try: - BlueprintInstance(path=path).retrieve() - except BlueprintRetrievalFailed as exc: - raise ValidationError(exc) from exc + """Ensure the path (if set) specified is retrievable""" + if path == "": + return path + files: list[dict] = blueprints_find_dict.delay().get() + if path not in [file["path"] for file in files]: + raise ValidationError(_("Blueprint file does not exist")) return path def validate_content(self, content: str) -> str: