authentik.enterprise.stages.authenticator_endpoint_gdtc.models
Endpoint stage
1"""Endpoint stage""" 2 3from uuid import uuid4 4 5from django.contrib.auth import get_user_model 6from django.db import models 7from django.utils.translation import gettext_lazy as _ 8from rest_framework.serializers import BaseSerializer, Serializer 9 10from authentik.core.types import UserSettingSerializer 11from authentik.flows.models import ConfigurableStage, FriendlyNamedStage, Stage 12from authentik.flows.stage import StageView 13from authentik.lib.models import DeprecatedMixin, InternallyManagedMixin, SerializerModel 14from authentik.stages.authenticator.models import Device 15 16 17class AuthenticatorEndpointGDTCStage(DeprecatedMixin, ConfigurableStage, FriendlyNamedStage, Stage): 18 """Verify Google Chrome Device Trust connection for the user's browser.""" 19 20 credentials = models.JSONField() 21 22 def google_credentials(self): 23 from google.oauth2.service_account import Credentials 24 25 return { 26 "credentials": Credentials.from_service_account_info( 27 self.credentials, scopes=["https://www.googleapis.com/auth/verifiedaccess"] 28 ), 29 } 30 31 @property 32 def serializer(self) -> type[BaseSerializer]: 33 from authentik.enterprise.stages.authenticator_endpoint_gdtc.api import ( 34 AuthenticatorEndpointGDTCStageSerializer, 35 ) 36 37 return AuthenticatorEndpointGDTCStageSerializer 38 39 @property 40 def view(self) -> type[StageView]: 41 from authentik.enterprise.stages.authenticator_endpoint_gdtc.stage import ( 42 AuthenticatorEndpointStageView, 43 ) 44 45 return AuthenticatorEndpointStageView 46 47 @property 48 def component(self) -> str: 49 return "ak-stage-authenticator-endpoint-gdtc-form" 50 51 def ui_user_settings(self) -> UserSettingSerializer | None: 52 return UserSettingSerializer( 53 data={ 54 "title": self.friendly_name or str(self._meta.verbose_name), 55 "component": "ak-user-settings-authenticator-endpoint", 56 } 57 ) 58 59 def __str__(self) -> str: 60 return f"Endpoint Authenticator Google Device Trust Connector Stage {self.name}" 61 62 class Meta: 63 verbose_name = _("Endpoint Authenticator Google Device Trust Connector Stage") 64 verbose_name_plural = _("Endpoint Authenticator Google Device Trust Connector Stages") 65 66 67class EndpointDevice(InternallyManagedMixin, SerializerModel, Device): 68 """Endpoint Device for a single user""" 69 70 uuid = models.UUIDField(primary_key=True, default=uuid4) 71 host_identifier = models.TextField( 72 unique=True, 73 help_text="A unique identifier for the endpoint device, usually the device serial number", 74 ) 75 76 user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) 77 data = models.JSONField() 78 79 @property 80 def serializer(self) -> Serializer: 81 from authentik.enterprise.stages.authenticator_endpoint_gdtc.api import ( 82 GoogleEndpointDeviceSerializer, 83 ) 84 85 return GoogleEndpointDeviceSerializer 86 87 def __str__(self): 88 return str(self.name) or str(self.user_id) 89 90 class Meta: 91 verbose_name = _("Endpoint Device") 92 verbose_name_plural = _("Endpoint Devices") 93 94 95class EndpointDeviceConnection(InternallyManagedMixin, models.Model): 96 device = models.ForeignKey(EndpointDevice, on_delete=models.CASCADE) 97 stage = models.ForeignKey(AuthenticatorEndpointGDTCStage, on_delete=models.CASCADE) 98 99 attributes = models.JSONField() 100 101 def __str__(self) -> str: 102 return f"Endpoint device connection {self.device_id} to {self.stage_id}"
18class AuthenticatorEndpointGDTCStage(DeprecatedMixin, ConfigurableStage, FriendlyNamedStage, Stage): 19 """Verify Google Chrome Device Trust connection for the user's browser.""" 20 21 credentials = models.JSONField() 22 23 def google_credentials(self): 24 from google.oauth2.service_account import Credentials 25 26 return { 27 "credentials": Credentials.from_service_account_info( 28 self.credentials, scopes=["https://www.googleapis.com/auth/verifiedaccess"] 29 ), 30 } 31 32 @property 33 def serializer(self) -> type[BaseSerializer]: 34 from authentik.enterprise.stages.authenticator_endpoint_gdtc.api import ( 35 AuthenticatorEndpointGDTCStageSerializer, 36 ) 37 38 return AuthenticatorEndpointGDTCStageSerializer 39 40 @property 41 def view(self) -> type[StageView]: 42 from authentik.enterprise.stages.authenticator_endpoint_gdtc.stage import ( 43 AuthenticatorEndpointStageView, 44 ) 45 46 return AuthenticatorEndpointStageView 47 48 @property 49 def component(self) -> str: 50 return "ak-stage-authenticator-endpoint-gdtc-form" 51 52 def ui_user_settings(self) -> UserSettingSerializer | None: 53 return UserSettingSerializer( 54 data={ 55 "title": self.friendly_name or str(self._meta.verbose_name), 56 "component": "ak-user-settings-authenticator-endpoint", 57 } 58 ) 59 60 def __str__(self) -> str: 61 return f"Endpoint Authenticator Google Device Trust Connector Stage {self.name}" 62 63 class Meta: 64 verbose_name = _("Endpoint Authenticator Google Device Trust Connector Stage") 65 verbose_name_plural = _("Endpoint Authenticator Google Device Trust Connector Stages")
Verify Google Chrome Device Trust connection for the user's browser.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
32 @property 33 def serializer(self) -> type[BaseSerializer]: 34 from authentik.enterprise.stages.authenticator_endpoint_gdtc.api import ( 35 AuthenticatorEndpointGDTCStageSerializer, 36 ) 37 38 return AuthenticatorEndpointGDTCStageSerializer
Get serializer for this model
40 @property 41 def view(self) -> type[StageView]: 42 from authentik.enterprise.stages.authenticator_endpoint_gdtc.stage import ( 43 AuthenticatorEndpointStageView, 44 ) 45 46 return AuthenticatorEndpointStageView
Return StageView class that implements logic for this stage
52 def ui_user_settings(self) -> UserSettingSerializer | None: 53 return UserSettingSerializer( 54 data={ 55 "title": self.friendly_name or str(self._meta.verbose_name), 56 "component": "ak-user-settings-authenticator-endpoint", 57 } 58 )
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.
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.
68class EndpointDevice(InternallyManagedMixin, SerializerModel, Device): 69 """Endpoint Device for a single user""" 70 71 uuid = models.UUIDField(primary_key=True, default=uuid4) 72 host_identifier = models.TextField( 73 unique=True, 74 help_text="A unique identifier for the endpoint device, usually the device serial number", 75 ) 76 77 user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) 78 data = models.JSONField() 79 80 @property 81 def serializer(self) -> Serializer: 82 from authentik.enterprise.stages.authenticator_endpoint_gdtc.api import ( 83 GoogleEndpointDeviceSerializer, 84 ) 85 86 return GoogleEndpointDeviceSerializer 87 88 def __str__(self): 89 return str(self.name) or str(self.user_id) 90 91 class Meta: 92 verbose_name = _("Endpoint Device") 93 verbose_name_plural = _("Endpoint Devices")
Endpoint Device for a single 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.
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.
80 @property 81 def serializer(self) -> Serializer: 82 from authentik.enterprise.stages.authenticator_endpoint_gdtc.api import ( 83 GoogleEndpointDeviceSerializer, 84 ) 85 86 return GoogleEndpointDeviceSerializer
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.
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.
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.
The requested object does not exist
The query returned multiple objects when only one was expected.
96class EndpointDeviceConnection(InternallyManagedMixin, models.Model): 97 device = models.ForeignKey(EndpointDevice, on_delete=models.CASCADE) 98 stage = models.ForeignKey(AuthenticatorEndpointGDTCStage, on_delete=models.CASCADE) 99 100 attributes = models.JSONField() 101 102 def __str__(self) -> str: 103 return f"Endpoint device connection {self.device_id} to {self.stage_id}"
EndpointDeviceConnection(id, device, stage, attributes)
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.
The requested object does not exist
The query returned multiple objects when only one was expected.