api: make config viewset single view

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-16 17:44:19 +02:00
parent 759bf59780
commit b351ae12c5
3 changed files with 7 additions and 10 deletions

View File

@ -4,7 +4,7 @@ from rest_framework.fields import BooleanField, CharField, ListField
from rest_framework.permissions import AllowAny from rest_framework.permissions import AllowAny
from rest_framework.request import Request from rest_framework.request import Request
from rest_framework.response import Response 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.core.api.utils import PassiveSerializer
from authentik.lib.config import CONFIG from authentik.lib.config import CONFIG
@ -29,13 +29,13 @@ class ConfigSerializer(PassiveSerializer):
error_reporting_send_pii = BooleanField(read_only=True) 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""" """Read-only view set that returns the current session's Configs"""
permission_classes = [AllowAny] permission_classes = [AllowAny]
@extend_schema(responses={200: ConfigSerializer(many=False)}) @extend_schema(responses={200: ConfigSerializer(many=False)})
def list(self, request: Request) -> Response: def get(self, request: Request) -> Response:
"""Retrive public configuration options""" """Retrive public configuration options"""
config = ConfigSerializer( config = ConfigSerializer(
{ {

View File

@ -8,7 +8,7 @@ from authentik.admin.api.metrics import AdministrationMetricsViewSet
from authentik.admin.api.tasks import TaskViewSet from authentik.admin.api.tasks import TaskViewSet
from authentik.admin.api.version import VersionViewSet from authentik.admin.api.version import VersionViewSet
from authentik.admin.api.workers import WorkerViewSet 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.api.views import APIBrowserView
from authentik.core.api.applications import ApplicationViewSet from authentik.core.api.applications import ApplicationViewSet
from authentik.core.api.groups import GroupViewSet from authentik.core.api.groups import GroupViewSet
@ -98,8 +98,6 @@ from authentik.stages.user_write.api import UserWriteStageViewSet
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register("root/config", ConfigsViewSet, basename="configs")
router.register("admin/version", VersionViewSet, basename="admin_version") router.register("admin/version", VersionViewSet, basename="admin_version")
router.register("admin/workers", WorkerViewSet, basename="admin_workers") router.register("admin/workers", WorkerViewSet, basename="admin_workers")
router.register("admin/metrics", AdministrationMetricsViewSet, basename="admin_metrics") router.register("admin/metrics", AdministrationMetricsViewSet, basename="admin_metrics")
@ -200,6 +198,7 @@ urlpatterns = (
] ]
+ router.urls + router.urls
+ [ + [
path("root/config/", ConfigView.as_view(), name="config"),
path( path(
"flows/executor/<slug:flow_slug>/", "flows/executor/<slug:flow_slug>/",
FlowExecutorView.as_view(), FlowExecutorView.as_view(),

View File

@ -8469,7 +8469,7 @@ paths:
description: Bad request description: Bad request
/api/v2beta/root/config/: /api/v2beta/root/config/:
get: get:
operationId: root_config_list operationId: root_config_retrieve
description: Retrive public configuration options description: Retrive public configuration options
tags: tags:
- root - root
@ -8482,9 +8482,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
type: array $ref: '#/components/schemas/Config'
items:
$ref: '#/components/schemas/Config'
description: '' description: ''
/api/v2beta/schema/: /api/v2beta/schema/:
get: get: