From 7a9140bdcd7298a9ea385e4bf30095ce974cd2ee Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 20 Feb 2021 23:42:35 +0100 Subject: [PATCH] core: move UILoginButtonSerializer into core --- authentik/core/types.py | 18 ++++++++++++++++++ authentik/stages/identification/stage.py | 18 ++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/authentik/core/types.py b/authentik/core/types.py index e7a46feb8..974c386d5 100644 --- a/authentik/core/types.py +++ b/authentik/core/types.py @@ -1,6 +1,10 @@ """authentik core dataclasses""" from dataclasses import dataclass from typing import Optional +from rest_framework.fields import CharField + +from rest_framework.serializers import Serializer +from django.db.models.base import Model @dataclass @@ -15,3 +19,17 @@ class UILoginButton: # Icon URL, used as-is icon_url: Optional[str] = None + + +class UILoginButtonSerializer(Serializer): + """Serializer for Login buttons of sources""" + + name = CharField() + url = CharField() + icon_url = CharField() + + def create(self, validated_data: dict) -> Model: + return Model() + + def update(self, instance: Model, validated_data: dict) -> Model: + return Model() diff --git a/authentik/stages/identification/stage.py b/authentik/stages/identification/stage.py index 08cc2130b..a05c7e802 100644 --- a/authentik/stages/identification/stage.py +++ b/authentik/stages/identification/stage.py @@ -1,14 +1,14 @@ """Identification stage logic""" +from authentik.core.types import UILoginButtonSerializer from dataclasses import asdict from typing import Optional from django.db.models import Q -from django.db.models.base import Model from django.http import HttpResponse from django.urls import reverse from django.utils.translation import gettext as _ from rest_framework.fields import CharField -from rest_framework.serializers import Serializer, ValidationError +from rest_framework.serializers import ValidationError from structlog.stdlib import get_logger from authentik.core.api.applications import ApplicationSerializer @@ -25,20 +25,6 @@ from authentik.stages.identification.models import IdentificationStage, UserFiel LOGGER = get_logger() -class UILoginButtonSerializer(Serializer): - """Serializer for Login buttons of sources""" - - name = CharField() - url = CharField() - icon_url = CharField() - - def create(self, validated_data: dict) -> Model: - return Model() - - def update(self, instance: Model, validated_data: dict) -> Model: - return Model() - - class IdentificationChallenge(Challenge): """Identification challenges with all UI elements"""