From c5870fcab2f246f7fc5fcd2dd54a5eb013fbe684 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 11 Feb 2023 21:08:29 +0100 Subject: [PATCH] core: fix missing uniqueness validator on user api closes #4665 Signed-off-by: Jens Langhammer --- authentik/core/api/users.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/authentik/core/api/users.py b/authentik/core/api/users.py index 17f784304..5ec51aa4e 100644 --- a/authentik/core/api/users.py +++ b/authentik/core/api/users.py @@ -43,6 +43,7 @@ from rest_framework.serializers import ( PrimaryKeyRelatedField, ValidationError, ) +from rest_framework.validators import UniqueValidator from rest_framework.viewsets import ModelViewSet from rest_framework_guardian.filters import ObjectPermissionsFilter from structlog.stdlib import get_logger @@ -107,7 +108,7 @@ class UserSerializer(ModelSerializer): ) groups_obj = ListSerializer(child=UserGroupSerializer(), read_only=True, source="ak_groups") uid = CharField(read_only=True) - username = CharField(max_length=150) + username = CharField(max_length=150, validators=[UniqueValidator(queryset=User.objects.all())]) def validate_path(self, path: str) -> str: """Validate path"""