From 7e47906475850b8869c7fb1c83c077e1d9130f75 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 21 Mar 2021 17:35:00 +0100 Subject: [PATCH] api: add Footer links to config API Signed-off-by: Jens Langhammer --- authentik/api/v2/config.py | 17 ++++++++++++++++- swagger.yaml | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/authentik/api/v2/config.py b/authentik/api/v2/config.py index 82c055fcd..e2ec1b1dc 100644 --- a/authentik/api/v2/config.py +++ b/authentik/api/v2/config.py @@ -1,7 +1,7 @@ """core Configs API""" from django.db.models import Model from drf_yasg2.utils import swagger_auto_schema -from rest_framework.fields import BooleanField, CharField +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 @@ -11,11 +11,25 @@ from rest_framework.viewsets import ViewSet from authentik.lib.config import CONFIG +class LinkSerializer(Serializer): + """Links returned in Config API""" + + href = CharField(read_only=True) + name = CharField(read_only=True) + + def create(self, validated_data: dict) -> Model: + raise NotImplementedError + + def update(self, instance: Model, validated_data: dict) -> Model: + raise NotImplementedError + + class ConfigSerializer(Serializer): """Serialize authentik Config into DRF Object""" branding_logo = CharField(read_only=True) branding_title = CharField(read_only=True) + ui_footer_links = ListField(child=LinkSerializer(), read_only=True) error_reporting_enabled = BooleanField(read_only=True) error_reporting_environment = CharField(read_only=True) @@ -43,6 +57,7 @@ class ConfigsViewSet(ViewSet): "error_reporting_enabled": CONFIG.y("error_reporting.enabled"), "error_reporting_environment": CONFIG.y("error_reporting.environment"), "error_reporting_send_pii": CONFIG.y("error_reporting.send_pii"), + "ui_footer_links": CONFIG.y("authentik.footer_links"), } ) return Response(config.data) diff --git a/swagger.yaml b/swagger.yaml index f13d22513..d94c14e3b 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -13331,6 +13331,20 @@ definitions: title: Metadata type: string readOnly: true + Link: + description: '' + type: object + properties: + href: + title: Href + type: string + readOnly: true + minLength: 1 + name: + title: Name + type: string + readOnly: true + minLength: 1 Config: description: Serialize authentik Config into DRF Object type: object @@ -13345,6 +13359,12 @@ definitions: type: string readOnly: true minLength: 1 + ui_footer_links: + description: '' + type: array + items: + $ref: '#/definitions/Link' + readOnly: true error_reporting_enabled: title: Error reporting enabled type: boolean