Skip to content

Commit 0ffaf03

Browse files
authored
stages/authenticator: add user field to devices (#12636)
Signed-off-by: Jens Langhammer <[email protected]>
1 parent 9bb3aa0 commit 0ffaf03

File tree

6 files changed

+43
-4
lines changed

6 files changed

+43
-4
lines changed

authentik/stages/authenticator_duo/api.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from rest_framework.viewsets import GenericViewSet, ModelViewSet
1313
from structlog.stdlib import get_logger
1414

15+
from authentik.core.api.groups import GroupMemberSerializer
1516
from authentik.core.api.used_by import UsedByMixin
1617
from authentik.core.api.utils import ModelSerializer
1718
from authentik.flows.api.stages import StageSerializer
@@ -165,9 +166,11 @@ def import_devices_automatic(self, request: Request, pk: str) -> Response:
165166
class DuoDeviceSerializer(ModelSerializer):
166167
"""Serializer for Duo authenticator devices"""
167168

169+
user = GroupMemberSerializer(read_only=True)
170+
168171
class Meta:
169172
model = DuoDevice
170-
fields = ["pk", "name"]
173+
fields = ["pk", "name", "user"]
171174
depth = 2
172175

173176

authentik/stages/authenticator_sms/api.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from rest_framework import mixins
44
from rest_framework.viewsets import GenericViewSet, ModelViewSet
55

6+
from authentik.core.api.groups import GroupMemberSerializer
67
from authentik.core.api.used_by import UsedByMixin
78
from authentik.core.api.utils import ModelSerializer
89
from authentik.flows.api.stages import StageSerializer
@@ -41,9 +42,11 @@ class AuthenticatorSMSStageViewSet(UsedByMixin, ModelViewSet):
4142
class SMSDeviceSerializer(ModelSerializer):
4243
"""Serializer for sms authenticator devices"""
4344

45+
user = GroupMemberSerializer(read_only=True)
46+
4447
class Meta:
4548
model = SMSDevice
46-
fields = ["name", "pk", "phone_number"]
49+
fields = ["name", "pk", "phone_number", "user"]
4750
depth = 2
4851
extra_kwargs = {
4952
"phone_number": {"read_only": True},

authentik/stages/authenticator_static/api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from rest_framework import mixins
44
from rest_framework.viewsets import GenericViewSet, ModelViewSet
55

6+
from authentik.core.api.groups import GroupMemberSerializer
67
from authentik.core.api.used_by import UsedByMixin
78
from authentik.core.api.utils import ModelSerializer
89
from authentik.flows.api.stages import StageSerializer
@@ -48,10 +49,11 @@ class StaticDeviceSerializer(ModelSerializer):
4849
"""Serializer for static authenticator devices"""
4950

5051
token_set = StaticDeviceTokenSerializer(many=True, read_only=True)
52+
user = GroupMemberSerializer(read_only=True)
5153

5254
class Meta:
5355
model = StaticDevice
54-
fields = ["name", "token_set", "pk"]
56+
fields = ["name", "token_set", "pk", "user"]
5557

5658

5759
class StaticDeviceViewSet(

authentik/stages/authenticator_totp/api.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from rest_framework.fields import ChoiceField
55
from rest_framework.viewsets import GenericViewSet, ModelViewSet
66

7+
from authentik.core.api.groups import GroupMemberSerializer
78
from authentik.core.api.used_by import UsedByMixin
89
from authentik.core.api.utils import ModelSerializer
910
from authentik.flows.api.stages import StageSerializer
@@ -37,11 +38,14 @@ class AuthenticatorTOTPStageViewSet(UsedByMixin, ModelViewSet):
3738
class TOTPDeviceSerializer(ModelSerializer):
3839
"""Serializer for totp authenticator devices"""
3940

41+
user = GroupMemberSerializer(read_only=True)
42+
4043
class Meta:
4144
model = TOTPDevice
4245
fields = [
4346
"name",
4447
"pk",
48+
"user",
4549
]
4650
depth = 2
4751

authentik/stages/authenticator_webauthn/api/devices.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from rest_framework import mixins
44
from rest_framework.viewsets import GenericViewSet, ModelViewSet
55

6+
from authentik.core.api.groups import GroupMemberSerializer
67
from authentik.core.api.used_by import UsedByMixin
78
from authentik.core.api.utils import ModelSerializer
89
from authentik.stages.authenticator_webauthn.api.device_types import WebAuthnDeviceTypeSerializer
@@ -13,10 +14,11 @@ class WebAuthnDeviceSerializer(ModelSerializer):
1314
"""Serializer for WebAuthn authenticator devices"""
1415

1516
device_type = WebAuthnDeviceTypeSerializer(read_only=True, allow_null=True)
17+
user = GroupMemberSerializer(read_only=True)
1618

1719
class Meta:
1820
model = WebAuthnDevice
19-
fields = ["pk", "name", "created_on", "device_type", "aaguid"]
21+
fields = ["pk", "name", "created_on", "device_type", "aaguid", "user"]
2022
extra_kwargs = {
2123
"aaguid": {"read_only": True},
2224
}

schema.yml

+25
Original file line numberDiff line numberDiff line change
@@ -41226,9 +41226,14 @@ components:
4122641226
type: string
4122741227
description: The human-readable name of this device.
4122841228
maxLength: 64
41229+
user:
41230+
allOf:
41231+
- $ref: '#/components/schemas/GroupMember'
41232+
readOnly: true
4122941233
required:
4123041234
- name
4123141235
- pk
41236+
- user
4123241237
DuoDeviceEnrollmentStatus:
4123341238
type: object
4123441239
properties:
@@ -54570,10 +54575,15 @@ components:
5457054575
phone_number:
5457154576
type: string
5457254577
readOnly: true
54578+
user:
54579+
allOf:
54580+
- $ref: '#/components/schemas/GroupMember'
54581+
readOnly: true
5457354582
required:
5457454583
- name
5457554584
- phone_number
5457654585
- pk
54586+
- user
5457754587
SMSDeviceRequest:
5457854588
type: object
5457954589
description: Serializer for sms authenticator devices
@@ -55275,10 +55285,15 @@ components:
5527555285
type: integer
5527655286
readOnly: true
5527755287
title: ID
55288+
user:
55289+
allOf:
55290+
- $ref: '#/components/schemas/GroupMember'
55291+
readOnly: true
5527855292
required:
5527955293
- name
5528055294
- pk
5528155295
- token_set
55296+
- user
5528255297
StaticDeviceRequest:
5528355298
type: object
5528455299
description: Serializer for static authenticator devices
@@ -55507,9 +55522,14 @@ components:
5550755522
type: integer
5550855523
readOnly: true
5550955524
title: ID
55525+
user:
55526+
allOf:
55527+
- $ref: '#/components/schemas/GroupMember'
55528+
readOnly: true
5551055529
required:
5551155530
- name
5551255531
- pk
55532+
- user
5551355533
TOTPDeviceRequest:
5551455534
type: object
5551555535
description: Serializer for totp authenticator devices
@@ -56951,12 +56971,17 @@ components:
5695156971
aaguid:
5695256972
type: string
5695356973
readOnly: true
56974+
user:
56975+
allOf:
56976+
- $ref: '#/components/schemas/GroupMember'
56977+
readOnly: true
5695456978
required:
5695556979
- aaguid
5695656980
- created_on
5695756981
- device_type
5695856982
- name
5695956983
- pk
56984+
- user
5696056985
WebAuthnDeviceRequest:
5696156986
type: object
5696256987
description: Serializer for WebAuthn authenticator devices

0 commit comments

Comments
 (0)