diff --git a/authentik/stages/authenticator_duo/api.py b/authentik/stages/authenticator_duo/api.py index bda0b2ca03..cccdd1dc1d 100644 --- a/authentik/stages/authenticator_duo/api.py +++ b/authentik/stages/authenticator_duo/api.py @@ -12,6 +12,7 @@ from rest_framework.response import Response from rest_framework.viewsets import GenericViewSet, ModelViewSet from structlog.stdlib import get_logger +from authentik.core.api.groups import GroupMemberSerializer from authentik.core.api.used_by import UsedByMixin from authentik.core.api.utils import ModelSerializer from authentik.flows.api.stages import StageSerializer @@ -165,9 +166,11 @@ class AuthenticatorDuoStageViewSet(UsedByMixin, ModelViewSet): class DuoDeviceSerializer(ModelSerializer): """Serializer for Duo authenticator devices""" + user = GroupMemberSerializer(read_only=True) + class Meta: model = DuoDevice - fields = ["pk", "name"] + fields = ["pk", "name", "user"] depth = 2 diff --git a/authentik/stages/authenticator_sms/api.py b/authentik/stages/authenticator_sms/api.py index 83c3f72782..4fd4db5a6d 100644 --- a/authentik/stages/authenticator_sms/api.py +++ b/authentik/stages/authenticator_sms/api.py @@ -3,6 +3,7 @@ from rest_framework import mixins from rest_framework.viewsets import GenericViewSet, ModelViewSet +from authentik.core.api.groups import GroupMemberSerializer from authentik.core.api.used_by import UsedByMixin from authentik.core.api.utils import ModelSerializer from authentik.flows.api.stages import StageSerializer @@ -41,9 +42,11 @@ class AuthenticatorSMSStageViewSet(UsedByMixin, ModelViewSet): class SMSDeviceSerializer(ModelSerializer): """Serializer for sms authenticator devices""" + user = GroupMemberSerializer(read_only=True) + class Meta: model = SMSDevice - fields = ["name", "pk", "phone_number"] + fields = ["name", "pk", "phone_number", "user"] depth = 2 extra_kwargs = { "phone_number": {"read_only": True}, diff --git a/authentik/stages/authenticator_static/api.py b/authentik/stages/authenticator_static/api.py index 5224418d49..edf83cf7fc 100644 --- a/authentik/stages/authenticator_static/api.py +++ b/authentik/stages/authenticator_static/api.py @@ -3,6 +3,7 @@ from rest_framework import mixins from rest_framework.viewsets import GenericViewSet, ModelViewSet +from authentik.core.api.groups import GroupMemberSerializer from authentik.core.api.used_by import UsedByMixin from authentik.core.api.utils import ModelSerializer from authentik.flows.api.stages import StageSerializer @@ -48,10 +49,11 @@ class StaticDeviceSerializer(ModelSerializer): """Serializer for static authenticator devices""" token_set = StaticDeviceTokenSerializer(many=True, read_only=True) + user = GroupMemberSerializer(read_only=True) class Meta: model = StaticDevice - fields = ["name", "token_set", "pk"] + fields = ["name", "token_set", "pk", "user"] class StaticDeviceViewSet( diff --git a/authentik/stages/authenticator_totp/api.py b/authentik/stages/authenticator_totp/api.py index b1c98c1713..940740f13a 100644 --- a/authentik/stages/authenticator_totp/api.py +++ b/authentik/stages/authenticator_totp/api.py @@ -4,6 +4,7 @@ from rest_framework import mixins from rest_framework.fields import ChoiceField from rest_framework.viewsets import GenericViewSet, ModelViewSet +from authentik.core.api.groups import GroupMemberSerializer from authentik.core.api.used_by import UsedByMixin from authentik.core.api.utils import ModelSerializer from authentik.flows.api.stages import StageSerializer @@ -37,11 +38,14 @@ class AuthenticatorTOTPStageViewSet(UsedByMixin, ModelViewSet): class TOTPDeviceSerializer(ModelSerializer): """Serializer for totp authenticator devices""" + user = GroupMemberSerializer(read_only=True) + class Meta: model = TOTPDevice fields = [ "name", "pk", + "user", ] depth = 2 diff --git a/authentik/stages/authenticator_webauthn/api/devices.py b/authentik/stages/authenticator_webauthn/api/devices.py index a1b14a8fa3..46e2109e52 100644 --- a/authentik/stages/authenticator_webauthn/api/devices.py +++ b/authentik/stages/authenticator_webauthn/api/devices.py @@ -3,6 +3,7 @@ from rest_framework import mixins from rest_framework.viewsets import GenericViewSet, ModelViewSet +from authentik.core.api.groups import GroupMemberSerializer from authentik.core.api.used_by import UsedByMixin from authentik.core.api.utils import ModelSerializer from authentik.stages.authenticator_webauthn.api.device_types import WebAuthnDeviceTypeSerializer @@ -13,10 +14,11 @@ class WebAuthnDeviceSerializer(ModelSerializer): """Serializer for WebAuthn authenticator devices""" device_type = WebAuthnDeviceTypeSerializer(read_only=True, allow_null=True) + user = GroupMemberSerializer(read_only=True) class Meta: model = WebAuthnDevice - fields = ["pk", "name", "created_on", "device_type", "aaguid"] + fields = ["pk", "name", "created_on", "device_type", "aaguid", "user"] extra_kwargs = { "aaguid": {"read_only": True}, } diff --git a/schema.yml b/schema.yml index c9b306e2e8..85d2875976 100644 --- a/schema.yml +++ b/schema.yml @@ -41226,9 +41226,14 @@ components: type: string description: The human-readable name of this device. maxLength: 64 + user: + allOf: + - $ref: '#/components/schemas/GroupMember' + readOnly: true required: - name - pk + - user DuoDeviceEnrollmentStatus: type: object properties: @@ -54570,10 +54575,15 @@ components: phone_number: type: string readOnly: true + user: + allOf: + - $ref: '#/components/schemas/GroupMember' + readOnly: true required: - name - phone_number - pk + - user SMSDeviceRequest: type: object description: Serializer for sms authenticator devices @@ -55275,10 +55285,15 @@ components: type: integer readOnly: true title: ID + user: + allOf: + - $ref: '#/components/schemas/GroupMember' + readOnly: true required: - name - pk - token_set + - user StaticDeviceRequest: type: object description: Serializer for static authenticator devices @@ -55507,9 +55522,14 @@ components: type: integer readOnly: true title: ID + user: + allOf: + - $ref: '#/components/schemas/GroupMember' + readOnly: true required: - name - pk + - user TOTPDeviceRequest: type: object description: Serializer for totp authenticator devices @@ -56951,12 +56971,17 @@ components: aaguid: type: string readOnly: true + user: + allOf: + - $ref: '#/components/schemas/GroupMember' + readOnly: true required: - aaguid - created_on - device_type - name - pk + - user WebAuthnDeviceRequest: type: object description: Serializer for WebAuthn authenticator devices