From bb64fb1130395b726826b801bb53bd3e42a24610 Mon Sep 17 00:00:00 2001 From: Jens L Date: Sun, 21 May 2023 15:19:05 +0200 Subject: [PATCH] core: make groups field for user optional (#5702) Signed-off-by: Jens Langhammer --- authentik/blueprints/migrations/0001_initial.py | 2 +- authentik/core/api/users.py | 2 +- blueprints/schema.json | 15 +++++---------- schema.yml | 2 -- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/authentik/blueprints/migrations/0001_initial.py b/authentik/blueprints/migrations/0001_initial.py index d0f897e76..53e831f24 100644 --- a/authentik/blueprints/migrations/0001_initial.py +++ b/authentik/blueprints/migrations/0001_initial.py @@ -45,7 +45,7 @@ def check_blueprint_v1_file(BlueprintInstance: type, path: Path): enabled=True, managed_models=[], last_applied_hash="", - metadata=metadata, + metadata=metadata or {}, ) instance.save() diff --git a/authentik/core/api/users.py b/authentik/core/api/users.py index 25346c469..9c2f9ed2c 100644 --- a/authentik/core/api/users.py +++ b/authentik/core/api/users.py @@ -106,7 +106,7 @@ class UserSerializer(ModelSerializer): avatar = CharField(read_only=True) attributes = JSONField(validators=[is_dict], required=False) groups = PrimaryKeyRelatedField( - allow_empty=True, many=True, source="ak_groups", queryset=Group.objects.all() + allow_empty=True, many=True, source="ak_groups", queryset=Group.objects.all(), default=list ) groups_obj = ListSerializer(child=UserGroupSerializer(), read_only=True, source="ak_groups") uid = CharField(read_only=True) diff --git a/blueprints/schema.json b/blueprints/schema.json index 6fd40ff43..ef4088f95 100644 --- a/blueprints/schema.json +++ b/blueprints/schema.json @@ -3888,8 +3888,7 @@ }, "required": [ "username", - "name", - "groups" + "name" ], "title": "User" }, @@ -4080,8 +4079,7 @@ }, "required": [ "username", - "name", - "groups" + "name" ], "title": "User" }, @@ -4276,8 +4274,7 @@ }, "required": [ "username", - "name", - "groups" + "name" ], "title": "User" }, @@ -6424,8 +6421,7 @@ }, "required": [ "username", - "name", - "groups" + "name" ], "title": "User" }, @@ -7160,8 +7156,7 @@ }, "required": [ "username", - "name", - "groups" + "name" ], "title": "User" }, diff --git a/schema.yml b/schema.yml index 91616f467..7f682cad8 100644 --- a/schema.yml +++ b/schema.yml @@ -41003,7 +41003,6 @@ components: type: string required: - avatar - - groups - groups_obj - is_superuser - name @@ -41461,7 +41460,6 @@ components: type: string minLength: 1 required: - - groups - name - username UserSAMLSourceConnection: