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.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(
{

View file

@ -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/<slug:flow_slug>/",
FlowExecutorView.as_view(),

View file

@ -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: