Compare commits

...

1 Commits

Author SHA1 Message Date
b3b50c5914 core: enforce unique group name on database level
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2024-12-11 18:12:39 +01:00
3 changed files with 22 additions and 4 deletions

View File

@ -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())]},
}

View File

@ -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"),
),
]

View File

@ -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.")
)