From b33ea9cc61b6735a92fec5dfbe423071c82b5ce2 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 9 Oct 2021 15:35:18 +0200 Subject: [PATCH] core: add settings serializer to user/me and update_self endpoints, saved in a key in attributes Signed-off-by: Jens Langhammer --- authentik/core/api/users.py | 4 +++- schema.yml | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/authentik/core/api/users.py b/authentik/core/api/users.py index 138054925..bdd6438c1 100644 --- a/authentik/core/api/users.py +++ b/authentik/core/api/users.py @@ -22,7 +22,7 @@ from drf_spectacular.utils import ( ) from guardian.shortcuts import get_anonymous_user, get_objects_for_user from rest_framework.decorators import action -from rest_framework.fields import CharField, JSONField, SerializerMethodField +from rest_framework.fields import CharField, DictField, JSONField, SerializerMethodField from rest_framework.permissions import IsAuthenticated from rest_framework.request import Request from rest_framework.response import Response @@ -103,6 +103,7 @@ class UserSelfSerializer(ModelSerializer): avatar = CharField(read_only=True) groups = SerializerMethodField() uid = CharField(read_only=True) + settings = DictField(source="attributes.settings") @extend_schema_field( ListSerializer( @@ -133,6 +134,7 @@ class UserSelfSerializer(ModelSerializer): "email", "avatar", "uid", + "settings", ] extra_kwargs = { "is_active": {"read_only": True}, diff --git a/schema.yml b/schema.yml index a8bf4d290..6eb3c9fb2 100644 --- a/schema.yml +++ b/schema.yml @@ -29295,6 +29295,9 @@ components: uid: type: string readOnly: true + settings: + type: object + additionalProperties: {} required: - avatar - groups @@ -29302,6 +29305,7 @@ components: - is_superuser - name - pk + - settings - uid - username UserSelfGroups: @@ -29336,8 +29340,12 @@ components: format: email title: Email address maxLength: 254 + settings: + type: object + additionalProperties: {} required: - name + - settings - username UserServiceAccountRequest: type: object