diff --git a/authentik/admin/api/version.py b/authentik/admin/api/version.py index 04d6d73c4..49b07f9be 100644 --- a/authentik/admin/api/version.py +++ b/authentik/admin/api/version.py @@ -5,11 +5,10 @@ from django.core.cache import cache from drf_spectacular.utils import extend_schema from packaging.version import parse from rest_framework.fields import SerializerMethodField -from rest_framework.mixins import ListModelMixin from rest_framework.permissions import IsAuthenticated from rest_framework.request import Request from rest_framework.response import Response -from rest_framework.viewsets import GenericViewSet +from rest_framework.views import APIView from authentik import ENV_GIT_HASH_KEY, __version__ from authentik.admin.tasks import VERSION_CACHE_KEY, update_latest_version @@ -47,17 +46,14 @@ class VersionSerializer(PassiveSerializer): ) -class VersionViewSet(ListModelMixin, GenericViewSet): +class VersionView(APIView): """Get running and latest version.""" permission_classes = [IsAuthenticated] pagination_class = None filter_backends = [] - def get_queryset(self): # pragma: no cover - return None - @extend_schema(responses={200: VersionSerializer(many=False)}) - def list(self, request: Request) -> Response: + def get(self, request: Request) -> Response: """Get running and latest version.""" return Response(VersionSerializer(True).data) diff --git a/authentik/api/v2/urls.py b/authentik/api/v2/urls.py index d141d3f3d..cf8a70b29 100644 --- a/authentik/api/v2/urls.py +++ b/authentik/api/v2/urls.py @@ -6,7 +6,7 @@ from rest_framework import routers from authentik.admin.api.meta import AppsViewSet from authentik.admin.api.metrics import AdministrationMetricsViewSet from authentik.admin.api.tasks import TaskViewSet -from authentik.admin.api.version import VersionViewSet +from authentik.admin.api.version import VersionView from authentik.admin.api.workers import WorkerViewSet from authentik.api.v2.config import ConfigView from authentik.api.views import APIBrowserView @@ -98,7 +98,6 @@ from authentik.stages.user_write.api import UserWriteStageViewSet router = routers.DefaultRouter() -router.register("admin/version", VersionViewSet, basename="admin_version") router.register("admin/workers", WorkerViewSet, basename="admin_workers") router.register("admin/system_tasks", TaskViewSet, basename="admin_system_tasks") router.register("admin/apps", AppsViewSet, basename="apps") @@ -198,6 +197,7 @@ urlpatterns = ( + router.urls + [ path("admin/metrics/", AdministrationMetricsViewSet.as_view(), name="admin_metrics"), + path("admin/version/", VersionView.as_view(), name="admin_version"), path("root/config/", ConfigView.as_view(), name="config"), path( "flows/executor//", diff --git a/schema.yml b/schema.yml index 1dff89e7f..9432c2bd6 100644 --- a/schema.yml +++ b/schema.yml @@ -121,7 +121,7 @@ paths: description: Failed to retry task /api/v2beta/admin/version/: get: - operationId: admin_version_list + operationId: admin_version_retrieve description: Get running and latest version. tags: - admin @@ -133,9 +133,7 @@ paths: content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Version' + $ref: '#/components/schemas/Version' description: '' /api/v2beta/admin/workers/: get: