diff --git a/authentik/core/api/devices.py b/authentik/core/api/devices.py index 555264fe15e0..14993ed9743c 100644 --- a/authentik/core/api/devices.py +++ b/authentik/core/api/devices.py @@ -17,6 +17,7 @@ from authentik.core.api.utils import MetaNameSerializer from authentik.stages.authenticator import device_classes, devices_for_user from authentik.stages.authenticator.models import Device +from authentik.stages.authenticator_webauthn.models import WebAuthnDevice class DeviceSerializer(MetaNameSerializer): @@ -29,11 +30,18 @@ class DeviceSerializer(MetaNameSerializer): created = DateTimeField(read_only=True) last_updated = DateTimeField(read_only=True) last_used = DateTimeField(read_only=True, allow_null=True) + extra_description = SerializerMethodField() def get_type(self, instance: Device) -> str: """Get type of device""" return instance._meta.label + def get_extra_description(self, instance: Device) -> str: + """Get extra description""" + if isinstance(instance, WebAuthnDevice): + return instance.device_type.description + return "" + class DeviceViewSet(ViewSet): """Viewset for authenticator devices""" diff --git a/schema.yml b/schema.yml index 3b8f749eadaf..507738a2d58f 100644 --- a/schema.yml +++ b/schema.yml @@ -38254,9 +38254,14 @@ components: format: date-time readOnly: true nullable: true + extra_description: + type: string + description: Get extra description + readOnly: true required: - confirmed - created + - extra_description - last_updated - last_used - meta_model_name diff --git a/web/src/admin/users/UserDevicesTable.ts b/web/src/admin/users/UserDevicesTable.ts index 6810ecb74bdb..20f11156fc4d 100644 --- a/web/src/admin/users/UserDevicesTable.ts +++ b/web/src/admin/users/UserDevicesTable.ts @@ -100,7 +100,8 @@ export class UserDeviceTable extends Table { row(item: Device): TemplateResult[] { return [ html`${item.name}`, - html`${deviceTypeName(item)}`, + html`${deviceTypeName(item)} + ${item.extraDescription ? ` - ${item.extraDescription}` : ""}`, html`${item.confirmed ? msg("Yes") : msg("No")}`, html`
${getRelativeTime(item.created)}
${item.created.toLocaleString()}`, diff --git a/web/src/user/user-settings/mfa/MFADevicesPage.ts b/web/src/user/user-settings/mfa/MFADevicesPage.ts index 3cfc5c66573e..85e72094e182 100644 --- a/web/src/user/user-settings/mfa/MFADevicesPage.ts +++ b/web/src/user/user-settings/mfa/MFADevicesPage.ts @@ -124,7 +124,8 @@ export class MFADevicesPage extends Table { row(item: Device): TemplateResult[] { return [ html`${item.name}`, - html`${deviceTypeName(item)}`, + html`${deviceTypeName(item)} + ${item.extraDescription ? ` - ${item.extraDescription}` : ""}`, html`${item.created.getTime() > 0 ? html`
${getRelativeTime(item.created)}
${item.created.toLocaleString()}`