Skip to content

Commit

Permalink
web/admin: display webauthn device type (#11481)
Browse files Browse the repository at this point in the history
* web/user,admin: display webauthn device type

Co-authored-by: Simonyi Gergő <[email protected]>
Signed-off-by: Marc 'risson' Schmitt <[email protected]>

* fix

Signed-off-by: Marc 'risson' Schmitt <[email protected]>

* fix 2

Signed-off-by: Jens Langhammer <[email protected]>

---------

Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Jens Langhammer <[email protected]>
Co-authored-by: Simonyi Gergő <[email protected]>
Co-authored-by: Jens Langhammer <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2024
1 parent 0a1d283 commit 10580d8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions authentik/core/api/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"""
Expand Down
5 changes: 5 additions & 0 deletions schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion web/src/admin/users/UserDevicesTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export class UserDeviceTable extends Table<Device> {
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`<div>${getRelativeTime(item.created)}</div>
<small>${item.created.toLocaleString()}</small>`,
Expand Down
3 changes: 2 additions & 1 deletion web/src/user/user-settings/mfa/MFADevicesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export class MFADevicesPage extends Table<Device> {
row(item: Device): TemplateResult[] {
return [
html`${item.name}`,
html`${deviceTypeName(item)}`,
html`${deviceTypeName(item)}
${item.extraDescription ? ` - ${item.extraDescription}` : ""}`,
html`${item.created.getTime() > 0
? html`<div>${getRelativeTime(item.created)}</div>
<small>${item.created.toLocaleString()}</small>`
Expand Down

0 comments on commit 10580d8

Please sign in to comment.