authentik.stages.authenticator_webauthn.models
WebAuthn stage
1"""WebAuthn stage""" 2 3from cryptography.x509 import Certificate, load_pem_x509_certificate 4from django.contrib.auth import get_user_model 5from django.contrib.postgres.fields.array import ArrayField 6from django.db import models 7from django.utils.timezone import now 8from django.utils.translation import gettext_lazy as _ 9from django.views import View 10from rest_framework.serializers import BaseSerializer, Serializer 11from webauthn.helpers.base64url_to_bytes import base64url_to_bytes 12from webauthn.helpers.structs import PublicKeyCredentialDescriptor 13 14from authentik.core.types import UserSettingSerializer 15from authentik.flows.models import ConfigurableStage, FriendlyNamedStage, Stage 16from authentik.lib.models import InternallyManagedMixin, SerializerModel, SimpleThroughModel 17from authentik.stages.authenticator.models import Device 18from authentik.stages.authenticator_webauthn.utils import validate_webauthn_origin 19 20UNKNOWN_DEVICE_TYPE_AAGUID = "00000000-0000-0000-0000-000000000000" 21 22 23class UserVerification(models.TextChoices): 24 """The degree to which the Relying Party wishes to verify a user's identity. 25 26 Members: 27 `REQUIRED`: User verification must occur 28 `PREFERRED`: User verification would be great, but if not that's okay too 29 `DISCOURAGED`: User verification should not occur, but it's okay if it does 30 31 https://www.w3.org/TR/webauthn-2/#enumdef-userverificationrequirement 32 """ 33 34 REQUIRED = "required" 35 PREFERRED = "preferred" 36 DISCOURAGED = "discouraged" 37 38 39class ResidentKeyRequirement(models.TextChoices): 40 """The Relying Party's preference for the authenticator to create a dedicated "client-side" 41 credential for it. Requiring an authenticator to store a dedicated credential should not be 42 done lightly due to the limited storage capacity of some types of authenticators. 43 44 Members: 45 `DISCOURAGED`: The authenticator should not create a dedicated credential 46 `PREFERRED`: The authenticator can create and store a dedicated credential, but if it 47 doesn't that's alright too 48 `REQUIRED`: The authenticator MUST create a dedicated credential. If it cannot, the RP 49 is prepared for an error to occur. 50 51 https://www.w3.org/TR/webauthn-2/#enum-residentKeyRequirement 52 """ 53 54 DISCOURAGED = "discouraged" 55 PREFERRED = "preferred" 56 REQUIRED = "required" 57 58 59class AuthenticatorAttachment(models.TextChoices): 60 """How an authenticator is connected to the client/browser. 61 62 Members: 63 `PLATFORM`: A non-removable authenticator, like TouchID or Windows Hello 64 `CROSS_PLATFORM`: A "roaming" authenticator, like a YubiKey 65 66 https://www.w3.org/TR/webauthn-2/#enumdef-authenticatorattachment 67 """ 68 69 PLATFORM = "platform" 70 CROSS_PLATFORM = "cross-platform" 71 72 73class WebAuthnHint(models.TextChoices): 74 """Hints to guide the browser in prioritizing the preferred authenticator during 75 WebAuthn registration and authentication. Unlike authenticatorAttachment, hints are 76 advisory and browsers may ignore them. 77 78 Members: 79 `SECURITY_KEY`: A portable FIDO2 authenticator, like a YubiKey 80 `CLIENT_DEVICE`: The device WebAuthn is being called on, like TouchID or Windows Hello 81 `HYBRID`: A platform authenticator on a mobile device, accessed via QR code 82 83 https://w3c.github.io/webauthn/#enumdef-publickeycredentialhint 84 """ 85 86 SECURITY_KEY = "security-key" 87 CLIENT_DEVICE = "client-device" 88 HYBRID = "hybrid" 89 90 91class AuthenticatorWebAuthnStage(ConfigurableStage, FriendlyNamedStage, Stage): 92 """Setup WebAuthn-based authentication for the user.""" 93 94 user_verification = models.TextField( 95 choices=UserVerification.choices, 96 default=UserVerification.PREFERRED, 97 ) 98 resident_key_requirement = models.TextField( 99 choices=ResidentKeyRequirement.choices, 100 default=ResidentKeyRequirement.PREFERRED, 101 ) 102 authenticator_attachment = models.TextField( # noqa: DJ001 103 choices=AuthenticatorAttachment.choices, default=None, null=True 104 ) 105 106 hints = ArrayField( 107 models.TextField(choices=WebAuthnHint.choices), 108 default=list, 109 blank=True, 110 ) 111 112 device_type_restrictions = models.ManyToManyField( 113 "WebAuthnDeviceType", blank=True, through="AuthenticatorWebAuthnStageDeviceTypeRestriction" 114 ) 115 116 max_attempts = models.PositiveIntegerField(default=0) 117 118 additional_accepted_origins = ArrayField( 119 models.TextField(validators=[validate_webauthn_origin]), 120 default=list, 121 db_default=[], 122 blank=True, 123 help_text=_("Additional trusted origins for WebAuthn registration. Matched exactly."), 124 ) 125 126 @property 127 def serializer(self) -> type[BaseSerializer]: 128 from authentik.stages.authenticator_webauthn.api.stages import ( 129 AuthenticatorWebAuthnStageSerializer, 130 ) 131 132 return AuthenticatorWebAuthnStageSerializer 133 134 @property 135 def view(self) -> type[View]: 136 from authentik.stages.authenticator_webauthn.stage import AuthenticatorWebAuthnStageView 137 138 return AuthenticatorWebAuthnStageView 139 140 @property 141 def component(self) -> str: 142 return "ak-stage-authenticator-webauthn-form" 143 144 def ui_user_settings(self) -> UserSettingSerializer | None: 145 return UserSettingSerializer( 146 data={ 147 "title": self.friendly_name or str(self._meta.verbose_name), 148 "component": "ak-user-settings-authenticator-webauthn", 149 } 150 ) 151 152 def __str__(self) -> str: 153 return f"WebAuthn Authenticator Setup Stage {self.name}" 154 155 class Meta: 156 verbose_name = _("WebAuthn Authenticator Setup Stage") 157 verbose_name_plural = _("WebAuthn Authenticator Setup Stages") 158 159 160class WebAuthnDevice(SerializerModel, Device): 161 """WebAuthn Device for a single user""" 162 163 user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) 164 165 name = models.TextField(max_length=200) 166 credential_id = models.TextField(unique=True) 167 public_key = models.TextField() 168 sign_count = models.IntegerField(default=0) 169 rp_id = models.CharField(max_length=253) 170 171 created_on = models.DateTimeField(auto_now_add=True) 172 last_t = models.DateTimeField(default=now) 173 174 attestation_certificate_pem = models.TextField(null=True, default=None) 175 attestation_certificate_fingerprint = models.TextField(null=True, default=None) 176 aaguid = models.TextField(default=UNKNOWN_DEVICE_TYPE_AAGUID) 177 device_type = models.ForeignKey( 178 "WebAuthnDeviceType", on_delete=models.SET_DEFAULT, null=True, default=None 179 ) 180 181 @property 182 def descriptor(self) -> PublicKeyCredentialDescriptor: 183 """Get a publickeydescriptor for this device""" 184 return PublicKeyCredentialDescriptor(id=base64url_to_bytes(self.credential_id)) 185 186 @property 187 def attestation_certificate(self) -> Certificate | None: 188 if not self.attestation_certificate_pem: 189 return None 190 return load_pem_x509_certificate(self.attestation_certificate_pem.encode()) 191 192 def set_sign_count(self, sign_count: int) -> None: 193 """Set the sign_count and update the last_t datetime.""" 194 self.sign_count = sign_count 195 self.last_t = now() 196 self.save() 197 198 @property 199 def serializer(self) -> Serializer: 200 from authentik.stages.authenticator_webauthn.api.devices import WebAuthnDeviceSerializer 201 202 return WebAuthnDeviceSerializer 203 204 def __str__(self): 205 return str(self.name) or str(self.user_id) 206 207 class Meta: 208 verbose_name = _("WebAuthn Device") 209 verbose_name_plural = _("WebAuthn Devices") 210 211 212class WebAuthnDeviceType(InternallyManagedMixin, SerializerModel): 213 """WebAuthn device type, used to restrict which device types are allowed""" 214 215 aaguid = models.UUIDField(primary_key=True, unique=True) 216 217 description = models.TextField() 218 icon = models.TextField(null=True) 219 220 @property 221 def serializer(self) -> Serializer: 222 from authentik.stages.authenticator_webauthn.api.device_types import ( 223 WebAuthnDeviceTypeSerializer, 224 ) 225 226 return WebAuthnDeviceTypeSerializer 227 228 class Meta: 229 verbose_name = _("WebAuthn Device type") 230 verbose_name_plural = _("WebAuthn Device types") 231 232 def __str__(self) -> str: 233 return f"WebAuthn device type {self.description} ({self.aaguid})" 234 235 236class AuthenticatorWebAuthnStageDeviceTypeRestriction(SimpleThroughModel): 237 authenticator_webauthn_stage = models.ForeignKey( 238 AuthenticatorWebAuthnStage, 239 on_delete=models.CASCADE, 240 db_column="authenticatorwebauthnstage_id", 241 ) 242 device_type_restriction = models.ForeignKey( 243 WebAuthnDeviceType, 244 on_delete=models.CASCADE, 245 db_column="webauthndevicetype_id", 246 ) 247 248 class Meta: 249 db_table = "authentik_stages_authenticator_webauthn_authenticatorwebaute3a7" 250 unique_together = (("authenticator_webauthn_stage", "device_type_restriction"),) 251 verbose_name = _("Authenticator WebAuthn Stage Device Type Restriction") 252 verbose_name_plural = _("Authenticator WebAuthn Stage Device Type Restrictions") 253 254 def __str__(self): 255 return ( 256 "AuthenticatorWebAuthnStageDeviceTypeRestriction for AuthenticatorWebAuthnStage " 257 f"{self.authenticator_webauthn_stage_id} " 258 f"and WebAuthnDeviceType {self.device_type_restriction_id}." 259 )
24class UserVerification(models.TextChoices): 25 """The degree to which the Relying Party wishes to verify a user's identity. 26 27 Members: 28 `REQUIRED`: User verification must occur 29 `PREFERRED`: User verification would be great, but if not that's okay too 30 `DISCOURAGED`: User verification should not occur, but it's okay if it does 31 32 https://www.w3.org/TR/webauthn-2/#enumdef-userverificationrequirement 33 """ 34 35 REQUIRED = "required" 36 PREFERRED = "preferred" 37 DISCOURAGED = "discouraged"
The degree to which the Relying Party wishes to verify a user's identity.
Members:
REQUIRED: User verification must occur
PREFERRED: User verification would be great, but if not that's okay too
DISCOURAGED: User verification should not occur, but it's okay if it does
https://www.w3.org/TR/webauthn-2/#enumdef-userverificationrequirement
40class ResidentKeyRequirement(models.TextChoices): 41 """The Relying Party's preference for the authenticator to create a dedicated "client-side" 42 credential for it. Requiring an authenticator to store a dedicated credential should not be 43 done lightly due to the limited storage capacity of some types of authenticators. 44 45 Members: 46 `DISCOURAGED`: The authenticator should not create a dedicated credential 47 `PREFERRED`: The authenticator can create and store a dedicated credential, but if it 48 doesn't that's alright too 49 `REQUIRED`: The authenticator MUST create a dedicated credential. If it cannot, the RP 50 is prepared for an error to occur. 51 52 https://www.w3.org/TR/webauthn-2/#enum-residentKeyRequirement 53 """ 54 55 DISCOURAGED = "discouraged" 56 PREFERRED = "preferred" 57 REQUIRED = "required"
The Relying Party's preference for the authenticator to create a dedicated "client-side" credential for it. Requiring an authenticator to store a dedicated credential should not be done lightly due to the limited storage capacity of some types of authenticators.
Members:
DISCOURAGED: The authenticator should not create a dedicated credential
PREFERRED: The authenticator can create and store a dedicated credential, but if it
doesn't that's alright too
REQUIRED: The authenticator MUST create a dedicated credential. If it cannot, the RP
is prepared for an error to occur.
https://www.w3.org/TR/webauthn-2/#enum-residentKeyRequirement
60class AuthenticatorAttachment(models.TextChoices): 61 """How an authenticator is connected to the client/browser. 62 63 Members: 64 `PLATFORM`: A non-removable authenticator, like TouchID or Windows Hello 65 `CROSS_PLATFORM`: A "roaming" authenticator, like a YubiKey 66 67 https://www.w3.org/TR/webauthn-2/#enumdef-authenticatorattachment 68 """ 69 70 PLATFORM = "platform" 71 CROSS_PLATFORM = "cross-platform"
How an authenticator is connected to the client/browser.
Members:
PLATFORM: A non-removable authenticator, like TouchID or Windows Hello
CROSS_PLATFORM: A "roaming" authenticator, like a YubiKey
https://www.w3.org/TR/webauthn-2/#enumdef-authenticatorattachment
74class WebAuthnHint(models.TextChoices): 75 """Hints to guide the browser in prioritizing the preferred authenticator during 76 WebAuthn registration and authentication. Unlike authenticatorAttachment, hints are 77 advisory and browsers may ignore them. 78 79 Members: 80 `SECURITY_KEY`: A portable FIDO2 authenticator, like a YubiKey 81 `CLIENT_DEVICE`: The device WebAuthn is being called on, like TouchID or Windows Hello 82 `HYBRID`: A platform authenticator on a mobile device, accessed via QR code 83 84 https://w3c.github.io/webauthn/#enumdef-publickeycredentialhint 85 """ 86 87 SECURITY_KEY = "security-key" 88 CLIENT_DEVICE = "client-device" 89 HYBRID = "hybrid"
Hints to guide the browser in prioritizing the preferred authenticator during WebAuthn registration and authentication. Unlike authenticatorAttachment, hints are advisory and browsers may ignore them.
Members:
SECURITY_KEY: A portable FIDO2 authenticator, like a YubiKey
CLIENT_DEVICE: The device WebAuthn is being called on, like TouchID or Windows Hello
HYBRID: A platform authenticator on a mobile device, accessed via QR code
https://w3c.github.io/webauthn/#enumdef-publickeycredentialhint
92class AuthenticatorWebAuthnStage(ConfigurableStage, FriendlyNamedStage, Stage): 93 """Setup WebAuthn-based authentication for the user.""" 94 95 user_verification = models.TextField( 96 choices=UserVerification.choices, 97 default=UserVerification.PREFERRED, 98 ) 99 resident_key_requirement = models.TextField( 100 choices=ResidentKeyRequirement.choices, 101 default=ResidentKeyRequirement.PREFERRED, 102 ) 103 authenticator_attachment = models.TextField( # noqa: DJ001 104 choices=AuthenticatorAttachment.choices, default=None, null=True 105 ) 106 107 hints = ArrayField( 108 models.TextField(choices=WebAuthnHint.choices), 109 default=list, 110 blank=True, 111 ) 112 113 device_type_restrictions = models.ManyToManyField( 114 "WebAuthnDeviceType", blank=True, through="AuthenticatorWebAuthnStageDeviceTypeRestriction" 115 ) 116 117 max_attempts = models.PositiveIntegerField(default=0) 118 119 additional_accepted_origins = ArrayField( 120 models.TextField(validators=[validate_webauthn_origin]), 121 default=list, 122 db_default=[], 123 blank=True, 124 help_text=_("Additional trusted origins for WebAuthn registration. Matched exactly."), 125 ) 126 127 @property 128 def serializer(self) -> type[BaseSerializer]: 129 from authentik.stages.authenticator_webauthn.api.stages import ( 130 AuthenticatorWebAuthnStageSerializer, 131 ) 132 133 return AuthenticatorWebAuthnStageSerializer 134 135 @property 136 def view(self) -> type[View]: 137 from authentik.stages.authenticator_webauthn.stage import AuthenticatorWebAuthnStageView 138 139 return AuthenticatorWebAuthnStageView 140 141 @property 142 def component(self) -> str: 143 return "ak-stage-authenticator-webauthn-form" 144 145 def ui_user_settings(self) -> UserSettingSerializer | None: 146 return UserSettingSerializer( 147 data={ 148 "title": self.friendly_name or str(self._meta.verbose_name), 149 "component": "ak-user-settings-authenticator-webauthn", 150 } 151 ) 152 153 def __str__(self) -> str: 154 return f"WebAuthn Authenticator Setup Stage {self.name}" 155 156 class Meta: 157 verbose_name = _("WebAuthn Authenticator Setup Stage") 158 verbose_name_plural = _("WebAuthn Authenticator Setup Stages")
Setup WebAuthn-based authentication for the user.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example::
class Pizza(Model):
toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings and Topping.pizzas are ManyToManyDescriptor
instances.
Most of the implementation is delegated to a dynamically defined manager
class built by create_forward_many_to_many_manager() defined below.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
127 @property 128 def serializer(self) -> type[BaseSerializer]: 129 from authentik.stages.authenticator_webauthn.api.stages import ( 130 AuthenticatorWebAuthnStageSerializer, 131 ) 132 133 return AuthenticatorWebAuthnStageSerializer
Get serializer for this model
135 @property 136 def view(self) -> type[View]: 137 from authentik.stages.authenticator_webauthn.stage import AuthenticatorWebAuthnStageView 138 139 return AuthenticatorWebAuthnStageView
Return StageView class that implements logic for this stage
145 def ui_user_settings(self) -> UserSettingSerializer | None: 146 return UserSettingSerializer( 147 data={ 148 "title": self.friendly_name or str(self._meta.verbose_name), 149 "component": "ak-user-settings-authenticator-webauthn", 150 } 151 )
Entrypoint to integrate with User settings. Can either return None if no user settings are available, or a challenge.
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Child.parent is a ForwardManyToOneDescriptor instance.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Accessor to the related object on the forward side of a one-to-one relation.
In the example::
class Restaurant(Model):
place = OneToOneField(Place, related_name='restaurant')
Restaurant.place is a ForwardOneToOneDescriptor instance.
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Parent.children is a ReverseManyToOneDescriptor instance.
Most of the implementation is delegated to a dynamically defined manager
class built by create_forward_many_to_many_manager() defined below.
Inherited Members
- authentik.flows.models.Stage
- stage_uuid
- name
- objects
- is_in_memory
- flow_set
- flowstagebinding_set
- emailstage
- passwordstage
- endpointstage
- invitationstage
- promptstage
- authenticatorstaticstage
- authenticatorduostage
- authenticatoremailstage
- authenticatorsmsstage
- authenticatorwebauthnstage
- authenticatorvalidatestage
- authenticator_validate_stage_m2m_objects
- captchastage
- identificationstage
- authenticatortotpstage
- consentstage
- denystage
- dummystage
- redirectstage
- userdeletestage
- userloginstage
- userlogoutstage
- userwritestage
- accountlockdownstage
- authenticatorendpointgdtcstage
- mutualtlsstage
- sourcestage
The requested object does not exist
The query returned multiple objects when only one was expected.
161class WebAuthnDevice(SerializerModel, Device): 162 """WebAuthn Device for a single user""" 163 164 user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) 165 166 name = models.TextField(max_length=200) 167 credential_id = models.TextField(unique=True) 168 public_key = models.TextField() 169 sign_count = models.IntegerField(default=0) 170 rp_id = models.CharField(max_length=253) 171 172 created_on = models.DateTimeField(auto_now_add=True) 173 last_t = models.DateTimeField(default=now) 174 175 attestation_certificate_pem = models.TextField(null=True, default=None) 176 attestation_certificate_fingerprint = models.TextField(null=True, default=None) 177 aaguid = models.TextField(default=UNKNOWN_DEVICE_TYPE_AAGUID) 178 device_type = models.ForeignKey( 179 "WebAuthnDeviceType", on_delete=models.SET_DEFAULT, null=True, default=None 180 ) 181 182 @property 183 def descriptor(self) -> PublicKeyCredentialDescriptor: 184 """Get a publickeydescriptor for this device""" 185 return PublicKeyCredentialDescriptor(id=base64url_to_bytes(self.credential_id)) 186 187 @property 188 def attestation_certificate(self) -> Certificate | None: 189 if not self.attestation_certificate_pem: 190 return None 191 return load_pem_x509_certificate(self.attestation_certificate_pem.encode()) 192 193 def set_sign_count(self, sign_count: int) -> None: 194 """Set the sign_count and update the last_t datetime.""" 195 self.sign_count = sign_count 196 self.last_t = now() 197 self.save() 198 199 @property 200 def serializer(self) -> Serializer: 201 from authentik.stages.authenticator_webauthn.api.devices import WebAuthnDeviceSerializer 202 203 return WebAuthnDeviceSerializer 204 205 def __str__(self): 206 return str(self.name) or str(self.user_id) 207 208 class Meta: 209 verbose_name = _("WebAuthn Device") 210 verbose_name_plural = _("WebAuthn Devices")
WebAuthn Device for a single user
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Child.parent is a ForwardManyToOneDescriptor instance.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Child.parent is a ForwardManyToOneDescriptor instance.
182 @property 183 def descriptor(self) -> PublicKeyCredentialDescriptor: 184 """Get a publickeydescriptor for this device""" 185 return PublicKeyCredentialDescriptor(id=base64url_to_bytes(self.credential_id))
Get a publickeydescriptor for this device
193 def set_sign_count(self, sign_count: int) -> None: 194 """Set the sign_count and update the last_t datetime.""" 195 self.sign_count = sign_count 196 self.last_t = now() 197 self.save()
Set the sign_count and update the last_t datetime.
199 @property 200 def serializer(self) -> Serializer: 201 from authentik.stages.authenticator_webauthn.api.devices import WebAuthnDeviceSerializer 202 203 return WebAuthnDeviceSerializer
Get serializer for this model
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
The requested object does not exist
The query returned multiple objects when only one was expected.
213class WebAuthnDeviceType(InternallyManagedMixin, SerializerModel): 214 """WebAuthn device type, used to restrict which device types are allowed""" 215 216 aaguid = models.UUIDField(primary_key=True, unique=True) 217 218 description = models.TextField() 219 icon = models.TextField(null=True) 220 221 @property 222 def serializer(self) -> Serializer: 223 from authentik.stages.authenticator_webauthn.api.device_types import ( 224 WebAuthnDeviceTypeSerializer, 225 ) 226 227 return WebAuthnDeviceTypeSerializer 228 229 class Meta: 230 verbose_name = _("WebAuthn Device type") 231 verbose_name_plural = _("WebAuthn Device types") 232 233 def __str__(self) -> str: 234 return f"WebAuthn device type {self.description} ({self.aaguid})"
WebAuthn device type, used to restrict which device types are allowed
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
221 @property 222 def serializer(self) -> Serializer: 223 from authentik.stages.authenticator_webauthn.api.device_types import ( 224 WebAuthnDeviceTypeSerializer, 225 ) 226 227 return WebAuthnDeviceTypeSerializer
Get serializer for this model
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example::
class Pizza(Model):
toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings and Topping.pizzas are ManyToManyDescriptor
instances.
Most of the implementation is delegated to a dynamically defined manager
class built by create_forward_many_to_many_manager() defined below.
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Parent.children is a ReverseManyToOneDescriptor instance.
Most of the implementation is delegated to a dynamically defined manager
class built by create_forward_many_to_many_manager() defined below.
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Parent.children is a ReverseManyToOneDescriptor instance.
Most of the implementation is delegated to a dynamically defined manager
class built by create_forward_many_to_many_manager() defined below.
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example::
class Pizza(Model):
toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings and Topping.pizzas are ManyToManyDescriptor
instances.
Most of the implementation is delegated to a dynamically defined manager
class built by create_forward_many_to_many_manager() defined below.
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Parent.children is a ReverseManyToOneDescriptor instance.
Most of the implementation is delegated to a dynamically defined manager
class built by create_forward_many_to_many_manager() defined below.
Inherited Members
The requested object does not exist
The query returned multiple objects when only one was expected.
237class AuthenticatorWebAuthnStageDeviceTypeRestriction(SimpleThroughModel): 238 authenticator_webauthn_stage = models.ForeignKey( 239 AuthenticatorWebAuthnStage, 240 on_delete=models.CASCADE, 241 db_column="authenticatorwebauthnstage_id", 242 ) 243 device_type_restriction = models.ForeignKey( 244 WebAuthnDeviceType, 245 on_delete=models.CASCADE, 246 db_column="webauthndevicetype_id", 247 ) 248 249 class Meta: 250 db_table = "authentik_stages_authenticator_webauthn_authenticatorwebaute3a7" 251 unique_together = (("authenticator_webauthn_stage", "device_type_restriction"),) 252 verbose_name = _("Authenticator WebAuthn Stage Device Type Restriction") 253 verbose_name_plural = _("Authenticator WebAuthn Stage Device Type Restrictions") 254 255 def __str__(self): 256 return ( 257 "AuthenticatorWebAuthnStageDeviceTypeRestriction for AuthenticatorWebAuthnStage " 258 f"{self.authenticator_webauthn_stage_id} " 259 f"and WebAuthnDeviceType {self.device_type_restriction_id}." 260 )
AuthenticatorWebAuthnStageDeviceTypeRestriction(id, authenticator_webauthn_stage, device_type_restriction)
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Child.parent is a ForwardManyToOneDescriptor instance.
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example::
class Child(Model):
parent = ForeignKey(Parent, related_name='children')
Child.parent is a ForwardManyToOneDescriptor instance.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
Inherited Members
The requested object does not exist
The query returned multiple objects when only one was expected.