From d79975c409857d0ec6b566e579e98b77fee0aa60 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 25 Aug 2021 20:43:34 +0200 Subject: [PATCH] core: fix user object for token not be setable Signed-off-by: Jens Langhammer --- authentik/core/api/tokens.py | 4 ++-- schema.yml | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/authentik/core/api/tokens.py b/authentik/core/api/tokens.py index c4f8e0b7c..d2b5905e4 100644 --- a/authentik/core/api/tokens.py +++ b/authentik/core/api/tokens.py @@ -23,7 +23,7 @@ from authentik.managed.api import ManagedSerializer class TokenSerializer(ManagedSerializer, ModelSerializer): """Token Serializer""" - user = UserSerializer(required=False) + user_obj = UserSerializer(required=False) def validate(self, attrs: dict[Any, str]) -> dict[Any, str]: """Ensure only API or App password tokens are created.""" @@ -41,11 +41,11 @@ class TokenSerializer(ManagedSerializer, ModelSerializer): "identifier", "intent", "user", + "user_obj", "description", "expires", "expiring", ] - depth = 2 class TokenViewSerializer(PassiveSerializer): diff --git a/schema.yml b/schema.yml index 94f66862e..7c87d9766 100644 --- a/schema.yml +++ b/schema.yml @@ -27876,6 +27876,8 @@ components: intent: $ref: '#/components/schemas/IntentEnum' user: + type: integer + user_obj: $ref: '#/components/schemas/UserRequest' description: type: string @@ -30055,6 +30057,8 @@ components: intent: $ref: '#/components/schemas/IntentEnum' user: + type: integer + user_obj: $ref: '#/components/schemas/User' description: type: string @@ -30066,6 +30070,7 @@ components: required: - identifier - pk + - user TokenRequest: type: object description: Token Serializer @@ -30085,6 +30090,8 @@ components: intent: $ref: '#/components/schemas/IntentEnum' user: + type: integer + user_obj: $ref: '#/components/schemas/UserRequest' description: type: string @@ -30095,6 +30102,7 @@ components: type: boolean required: - identifier + - user TokenView: type: object description: Show token's current key