From 70c7454c6951d65d3e38a71056eb81d3a3a79872 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 4 Jul 2024 12:52:26 +0200 Subject: [PATCH] return authentik launch URL Signed-off-by: Jens Langhammer --- authentik/core/api/applications.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/authentik/core/api/applications.py b/authentik/core/api/applications.py index 6e6db93df5..e3e4d8a111 100644 --- a/authentik/core/api/applications.py +++ b/authentik/core/api/applications.py @@ -8,6 +8,7 @@ from django.core.cache import cache from django.db.models import QuerySet from django.db.models.functions import ExtractHour from django.shortcuts import get_object_or_404 +from django.urls import reverse from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema from guardian.shortcuts import get_objects_for_user @@ -65,10 +66,12 @@ class ApplicationSerializer(ModelSerializer): def get_launch_url(self, app: Application) -> str | None: """Allow formatting of launch URL""" - user = None - if "request" in self.context: - user = self.context["request"].user - return app.get_launch_url(user) + return reverse( + "authentik_core:application-launch", + kwargs={ + "application_slug": app.slug, + }, + ) def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs)