diff --git a/authentik/core/api/groups.py b/authentik/core/api/groups.py index fd9358152b..ab5e1d8424 100644 --- a/authentik/core/api/groups.py +++ b/authentik/core/api/groups.py @@ -103,9 +103,6 @@ class GroupSerializer(ModelSerializer): "users": { "default": list, }, - # TODO: This field isn't unique on the database which is hard to backport - # hence we just validate the uniqueness here - "name": {"validators": [UniqueValidator(Group.objects.all())]}, } diff --git a/authentik/core/migrations/0040_alter_group_name.py b/authentik/core/migrations/0040_alter_group_name.py new file mode 100644 index 0000000000..42620eea42 --- /dev/null +++ b/authentik/core/migrations/0040_alter_group_name.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.8 on 2024-08-08 12:09 + +from django.db import migrations, models + +from authentik.lib.migrations import fallback_names + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_core", "0039_source_group_matching_mode_alter_group_name_and_more"), + ] + + operations = [ + migrations.RunPython(fallback_names("authentik_core", "group", "name")), + migrations.AlterField( + model_name="group", + name="name", + field=models.TextField(unique=True, verbose_name="name"), + ), + ] diff --git a/authentik/core/models.py b/authentik/core/models.py index 85e8901ed1..62fb3238cc 100644 --- a/authentik/core/models.py +++ b/authentik/core/models.py @@ -173,7 +173,7 @@ class Group(SerializerModel, AttributesMixin): group_uuid = models.UUIDField(primary_key=True, editable=False, default=uuid4) - name = models.TextField(_("name")) + name = models.TextField(verbose_name=_("name"), unique=True) is_superuser = models.BooleanField( default=False, help_text=_("Users added to this group will be superusers.") )