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