From 16a03160d05fbed5bdc549e968ef24e5a24c8ad4 Mon Sep 17 00:00:00 2001 From: sdimovv <36302090+sdimovv@users.noreply.github.com> Date: Mon, 20 Mar 2023 01:33:08 +0200 Subject: [PATCH] core: Add unique constraint to user UUID (#5004) --- .../core/migrations/0027_alter_user_uuid.py | 19 +++++++++++++++++++ authentik/core/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 authentik/core/migrations/0027_alter_user_uuid.py diff --git a/authentik/core/migrations/0027_alter_user_uuid.py b/authentik/core/migrations/0027_alter_user_uuid.py new file mode 100644 index 000000000..11e8c62bd --- /dev/null +++ b/authentik/core/migrations/0027_alter_user_uuid.py @@ -0,0 +1,19 @@ +# Generated by Django 4.1.7 on 2023-03-19 21:57 + +import uuid + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("authentik_core", "0026_alter_propertymapping_name_alter_provider_name"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="uuid", + field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True), + ), + ] diff --git a/authentik/core/models.py b/authentik/core/models.py index ab2434e5b..52b5b637a 100644 --- a/authentik/core/models.py +++ b/authentik/core/models.py @@ -146,7 +146,7 @@ class UserManager(DjangoUserManager): class User(SerializerModel, GuardianUserMixin, AbstractUser): """Custom User model to allow easier adding of user-based settings""" - uuid = models.UUIDField(default=uuid4, editable=False) + uuid = models.UUIDField(default=uuid4, editable=False, unique=True) name = models.TextField(help_text=_("User's display name.")) path = models.TextField(default="users")