From 93e20bce2e10ad5f6c641c13c9fce1df0b1b8f89 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 1 Jan 2023 23:16:44 +0100 Subject: [PATCH] core: don't use inline_serializer for user operations Signed-off-by: Jens Langhammer --- authentik/core/api/groups.py | 22 +++++++++------------- schema.yml | 1 + 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/authentik/core/api/groups.py b/authentik/core/api/groups.py index 2ab4ff7f5..4ba6af910 100644 --- a/authentik/core/api/groups.py +++ b/authentik/core/api/groups.py @@ -17,7 +17,7 @@ from rest_framework_guardian.filters import ObjectPermissionsFilter from authentik.api.decorators import permission_required from authentik.core.api.used_by import UsedByMixin -from authentik.core.api.utils import is_dict +from authentik.core.api.utils import PassiveSerializer, is_dict from authentik.core.models import Group, User @@ -120,6 +120,12 @@ class GroupFilter(FilterSet): fields = ["name", "is_superuser", "members_by_pk", "attributes", "members_by_username"] +class UserAccountSerializer(PassiveSerializer): + """Account adding/removing operations""" + + pk = IntegerField(required=True) + + class GroupViewSet(UsedByMixin, ModelViewSet): """Group Viewset""" @@ -144,12 +150,7 @@ class GroupViewSet(UsedByMixin, ModelViewSet): @permission_required(None, ["authentik_core.add_user"]) @extend_schema( - request=inline_serializer( - "UserAccountSerializer", - { - "pk": IntegerField(required=True), - }, - ), + request=UserAccountSerializer, responses={ 204: OpenApiResponse(description="User added"), 404: OpenApiResponse(description="User not found"), @@ -174,12 +175,7 @@ class GroupViewSet(UsedByMixin, ModelViewSet): @permission_required(None, ["authentik_core.add_user"]) @extend_schema( - request=inline_serializer( - "UserAccountSerializer", - { - "pk": IntegerField(required=True), - }, - ), + request=UserAccountSerializer, responses={ 204: OpenApiResponse(description="User added"), 404: OpenApiResponse(description="User not found"), diff --git a/schema.yml b/schema.yml index 28a354a69..cfdfed2df 100644 --- a/schema.yml +++ b/schema.yml @@ -37940,6 +37940,7 @@ components: - username UserAccountRequest: type: object + description: Account adding/removing operations properties: pk: type: integer