core: don't use inline_serializer for user operations

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2023-01-01 23:16:44 +01:00
parent 960a2aab74
commit 93e20bce2e
No known key found for this signature in database
2 changed files with 10 additions and 13 deletions

View file

@ -17,7 +17,7 @@ from rest_framework_guardian.filters import ObjectPermissionsFilter
from authentik.api.decorators import permission_required from authentik.api.decorators import permission_required
from authentik.core.api.used_by import UsedByMixin 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 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"] 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): class GroupViewSet(UsedByMixin, ModelViewSet):
"""Group Viewset""" """Group Viewset"""
@ -144,12 +150,7 @@ class GroupViewSet(UsedByMixin, ModelViewSet):
@permission_required(None, ["authentik_core.add_user"]) @permission_required(None, ["authentik_core.add_user"])
@extend_schema( @extend_schema(
request=inline_serializer( request=UserAccountSerializer,
"UserAccountSerializer",
{
"pk": IntegerField(required=True),
},
),
responses={ responses={
204: OpenApiResponse(description="User added"), 204: OpenApiResponse(description="User added"),
404: OpenApiResponse(description="User not found"), 404: OpenApiResponse(description="User not found"),
@ -174,12 +175,7 @@ class GroupViewSet(UsedByMixin, ModelViewSet):
@permission_required(None, ["authentik_core.add_user"]) @permission_required(None, ["authentik_core.add_user"])
@extend_schema( @extend_schema(
request=inline_serializer( request=UserAccountSerializer,
"UserAccountSerializer",
{
"pk": IntegerField(required=True),
},
),
responses={ responses={
204: OpenApiResponse(description="User added"), 204: OpenApiResponse(description="User added"),
404: OpenApiResponse(description="User not found"), 404: OpenApiResponse(description="User not found"),

View file

@ -37940,6 +37940,7 @@ components:
- username - username
UserAccountRequest: UserAccountRequest:
type: object type: object
description: Account adding/removing operations
properties: properties:
pk: pk:
type: integer type: integer