api: add Footer links to config API

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-03-21 17:35:00 +01:00
parent 24ac6d2c25
commit 7e47906475
2 changed files with 36 additions and 1 deletions

View file

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

View file

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