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