From b351ae12c5e49e2b2959b46540c9211f4d9aa53a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 16 May 2021 17:44:19 +0200 Subject: [PATCH] api: make config viewset single view Signed-off-by: Jens Langhammer --- authentik/api/v2/config.py | 6 +++--- authentik/api/v2/urls.py | 5 ++--- schema.yml | 6 ++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/authentik/api/v2/config.py b/authentik/api/v2/config.py index 49e9f508a..078f0e5a3 100644 --- a/authentik/api/v2/config.py +++ b/authentik/api/v2/config.py @@ -4,7 +4,7 @@ from rest_framework.fields import BooleanField, CharField, ListField from rest_framework.permissions import AllowAny from rest_framework.request import Request from rest_framework.response import Response -from rest_framework.viewsets import ViewSet +from rest_framework.views import APIView from authentik.core.api.utils import PassiveSerializer from authentik.lib.config import CONFIG @@ -29,13 +29,13 @@ class ConfigSerializer(PassiveSerializer): error_reporting_send_pii = BooleanField(read_only=True) -class ConfigsViewSet(ViewSet): +class ConfigView(APIView): """Read-only view set that returns the current session's Configs""" permission_classes = [AllowAny] @extend_schema(responses={200: ConfigSerializer(many=False)}) - def list(self, request: Request) -> Response: + def get(self, request: Request) -> Response: """Retrive public configuration options""" config = ConfigSerializer( { diff --git a/authentik/api/v2/urls.py b/authentik/api/v2/urls.py index 70131035a..e63baaf85 100644 --- a/authentik/api/v2/urls.py +++ b/authentik/api/v2/urls.py @@ -8,7 +8,7 @@ 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.workers import WorkerViewSet -from authentik.api.v2.config import ConfigsViewSet +from authentik.api.v2.config import ConfigView from authentik.api.views import APIBrowserView from authentik.core.api.applications import ApplicationViewSet from authentik.core.api.groups import GroupViewSet @@ -98,8 +98,6 @@ from authentik.stages.user_write.api import UserWriteStageViewSet router = routers.DefaultRouter() -router.register("root/config", ConfigsViewSet, basename="configs") - router.register("admin/version", VersionViewSet, basename="admin_version") router.register("admin/workers", WorkerViewSet, basename="admin_workers") router.register("admin/metrics", AdministrationMetricsViewSet, basename="admin_metrics") @@ -200,6 +198,7 @@ urlpatterns = ( ] + router.urls + [ + path("root/config/", ConfigView.as_view(), name="config"), path( "flows/executor//", FlowExecutorView.as_view(), diff --git a/schema.yml b/schema.yml index b190f79da..3a89297ca 100644 --- a/schema.yml +++ b/schema.yml @@ -8469,7 +8469,7 @@ paths: description: Bad request /api/v2beta/root/config/: get: - operationId: root_config_list + operationId: root_config_retrieve description: Retrive public configuration options tags: - root @@ -8482,9 +8482,7 @@ paths: content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Config' + $ref: '#/components/schemas/Config' description: '' /api/v2beta/schema/: get: