authentik.endpoints.connectors.agent.models

  1from typing import TYPE_CHECKING
  2from uuid import uuid4
  3
  4from django.db import models
  5from django.templatetags.static import static
  6from django.utils.translation import gettext_lazy as _
  7from rest_framework.serializers import Serializer
  8
  9from authentik.core.models import User, default_token_key
 10from authentik.crypto.models import CertificateKeyPair
 11from authentik.endpoints.models import (
 12    Connector,
 13    Device,
 14    DeviceAccessGroup,
 15    DeviceConnection,
 16    DeviceUserBinding,
 17)
 18from authentik.flows.stage import StageView
 19from authentik.lib.generators import generate_id, generate_key
 20from authentik.lib.models import (
 21    ExpiringModel,
 22    InternallyManagedMixin,
 23    SerializerModel,
 24    SimpleThroughModel,
 25)
 26from authentik.lib.utils.time import timedelta_string_validator
 27from authentik.stages.authenticator.models import Device as Authenticator
 28
 29if TYPE_CHECKING:
 30    from authentik.endpoints.connectors.agent.controller import AgentConnectorController
 31
 32
 33class AgentConnector(Connector):
 34    """Configure authentication and add device compliance using the authentik Agent."""
 35
 36    refresh_interval = models.TextField(
 37        default="minutes=30",
 38        validators=[timedelta_string_validator],
 39    )
 40
 41    auth_session_duration = models.TextField(
 42        default="hours=8", validators=[timedelta_string_validator]
 43    )
 44    auth_terminate_session_on_expiry = models.BooleanField(default=False)
 45    authorization_flow = models.ForeignKey(
 46        "authentik_flows.Flow", null=True, on_delete=models.SET_DEFAULT, default=None
 47    )
 48    jwt_federation_providers = models.ManyToManyField(
 49        "authentik_providers_oauth2.OAuth2Provider",
 50        blank=True,
 51        default=None,
 52        through="AgentConnectorJWTFederationProvider",
 53    )
 54
 55    nss_uid_offset = models.PositiveIntegerField(default=1000)
 56    nss_gid_offset = models.PositiveIntegerField(default=1000)
 57
 58    challenge_key = models.ForeignKey(CertificateKeyPair, on_delete=models.CASCADE, null=True)
 59    challenge_idle_timeout = models.TextField(
 60        validators=[timedelta_string_validator], default="seconds=5"
 61    )
 62    challenge_trigger_check_in = models.BooleanField(default=False)
 63
 64    @property
 65    def icon_url(self):
 66        return static("dist/assets/icons/icon.svg")
 67
 68    @property
 69    def serializer(self) -> type[Serializer]:
 70        from authentik.endpoints.connectors.agent.api.connectors import (
 71            AgentConnectorSerializer,
 72        )
 73
 74        return AgentConnectorSerializer
 75
 76    @property
 77    def stage(self) -> type[StageView] | None:
 78        from authentik.endpoints.connectors.agent.stage import (
 79            AuthenticatorEndpointStageView,
 80        )
 81
 82        return AuthenticatorEndpointStageView
 83
 84    @property
 85    def controller(self) -> type[AgentConnectorController]:
 86        from authentik.endpoints.connectors.agent.controller import AgentConnectorController
 87
 88        return AgentConnectorController
 89
 90    @property
 91    def component(self) -> str:
 92        return "ak-endpoints-connector-agent-form"
 93
 94    class Meta:
 95        verbose_name = _("Agent Connector")
 96        verbose_name_plural = _("Agent Connectors")
 97
 98
 99class AgentConnectorJWTFederationProvider(SimpleThroughModel):
100    agent_connector = models.ForeignKey(
101        AgentConnector, on_delete=models.CASCADE, db_column="agentconnector_id"
102    )
103    oauth2_provider = models.ForeignKey(
104        "authentik_providers_oauth2.OAuth2Provider",
105        on_delete=models.CASCADE,
106        db_column="oauth2provider_id",
107    )
108
109    class Meta:
110        db_table = "authentik_endpoints_connectors_agent_agentconnector_jwt_fed2bc6"
111        unique_together = (("agent_connector", "oauth2_provider"),)
112        verbose_name = _("Agent Connector JWT Federation Provider")
113        verbose_name_plural = _("Agent Connector JWT Federation Providers")
114
115    def __str__(self):
116        return (
117            f"AgentConnectorJWTFederationProvider for AgentConnector {self.agent_connector_id} "
118            f"and OAuth2Provider {self.oauth2_provider_id}."
119        )
120
121
122class AgentDeviceConnection(DeviceConnection):
123
124    apple_key_exchange_key = models.TextField()
125    apple_encryption_key = models.TextField()
126    apple_enc_key_id = models.TextField()
127    apple_signing_key = models.TextField()
128    apple_sign_key_id = models.TextField()
129
130
131class AgentDeviceUserBinding(DeviceUserBinding):
132
133    apple_secure_enclave_key = models.TextField()
134    apple_enclave_key_id = models.TextField()
135
136    class Meta:
137        verbose_name = _("Agent Device User binding")
138        verbose_name_plural = _("Agent Device User bindings")
139
140
141class DeviceToken(InternallyManagedMixin, ExpiringModel):
142    """Per-device token used for authentication."""
143
144    token_uuid = models.UUIDField(primary_key=True, default=uuid4)
145    device = models.ForeignKey(AgentDeviceConnection, on_delete=models.CASCADE)
146    key = models.TextField(default=generate_key)
147
148    class Meta:
149        verbose_name = _("Device Token")
150        verbose_name_plural = _("Device Tokens")
151        indexes = ExpiringModel.Meta.indexes + [
152            models.Index(fields=["key"]),
153        ]
154
155
156class EnrollmentToken(ExpiringModel, SerializerModel):
157    """Token used during enrollment, a device will receive
158    a device token for further authentication"""
159
160    token_uuid = models.UUIDField(primary_key=True, editable=False, default=uuid4)
161    name = models.TextField()
162    key = models.TextField(default=default_token_key)
163    connector = models.ForeignKey(AgentConnector, on_delete=models.CASCADE)
164    device_group = models.ForeignKey(
165        DeviceAccessGroup, on_delete=models.SET_DEFAULT, default=None, null=True
166    )
167
168    @property
169    def serializer(self) -> type[Serializer]:
170        from authentik.endpoints.connectors.agent.api.enrollment_tokens import (
171            EnrollmentTokenSerializer,
172        )
173
174        return EnrollmentTokenSerializer
175
176    class Meta:
177        verbose_name = _("Enrollment Token")
178        verbose_name_plural = _("Enrollment Tokens")
179        indexes = ExpiringModel.Meta.indexes + [
180            models.Index(fields=["key"]),
181        ]
182        permissions = [
183            ("view_enrollment_token_key", _("View token's key")),
184        ]
185
186
187class DeviceAuthenticationToken(InternallyManagedMixin, ExpiringModel):
188
189    identifier = models.UUIDField(default=uuid4, primary_key=True)
190    device = models.ForeignKey(Device, on_delete=models.CASCADE)
191    device_token = models.ForeignKey(DeviceToken, on_delete=models.CASCADE)
192    connector = models.ForeignKey(AgentConnector, on_delete=models.CASCADE)
193    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, default=None)
194    token = models.TextField()
195
196    def __str__(self):
197        return f"Device authentication token {self.identifier}"
198
199    class Meta(ExpiringModel.Meta):
200        verbose_name = _("Device authentication token")
201        verbose_name_plural = _("Device authentication tokens")
202
203
204class AppleNonce(InternallyManagedMixin, ExpiringModel):
205    nonce = models.TextField()
206    device_token = models.ForeignKey(DeviceToken, on_delete=models.CASCADE)
207
208    class Meta(ExpiringModel.Meta):
209        verbose_name = _("Apple Nonce")
210        verbose_name_plural = _("Apple Nonces")
211
212
213class AppleAuthorizationCode(InternallyManagedMixin, ExpiringModel):
214    """Short-lived code issued by the authorize endpoint, exchanged for tokens."""
215
216    code = models.TextField(default=generate_id)
217    user = models.ForeignKey(User, on_delete=models.CASCADE)
218    connector = models.ForeignKey("AgentConnector", on_delete=models.CASCADE)
219    # The device the code was issued to, it is the only one allowed to redeem it
220    device_connection = models.ForeignKey(AgentDeviceConnection, on_delete=models.CASCADE)
221    state = models.TextField(default="")
222    scope = models.TextField()
223
224    class Meta(ExpiringModel.Meta):
225        verbose_name = _("Apple Authorization Code")
226        verbose_name_plural = _("Apple Authorization Codes")
227        indexes = ExpiringModel.Meta.indexes + [
228            models.Index(fields=["code"]),
229        ]
230
231
232class AppleUnlockKey(InternallyManagedMixin, ExpiringModel):
233    """Server-provisioned EC256 key for Platform SSO v2.0 user_unlock."""
234
235    identifier = models.UUIDField(primary_key=True, default=uuid4)
236    device_user = models.ForeignKey(AgentDeviceUserBinding, on_delete=models.CASCADE)
237    private_key = models.TextField()
238    certificate_der = models.TextField(default="")
239
240    class Meta(ExpiringModel.Meta):
241        verbose_name = _("Apple Unlock Key")
242        verbose_name_plural = _("Apple Unlock Keys")
243
244
245class AppleIndependentSecureEnclave(Authenticator):
246    """A device-independent secure enclave key, used by Tap-to-login"""
247
248    uuid = models.UUIDField(primary_key=True, default=uuid4)
249
250    apple_secure_enclave_key = models.TextField()
251    apple_enclave_key_id = models.TextField()
252    device_type = models.TextField()
253
254    class Meta:
255        verbose_name = _("Apple Independent Secure Enclave")
256        verbose_name_plural = _("Apple Independent Secure Enclaves")
class AgentConnector(authentik.endpoints.models.Connector):
34class AgentConnector(Connector):
35    """Configure authentication and add device compliance using the authentik Agent."""
36
37    refresh_interval = models.TextField(
38        default="minutes=30",
39        validators=[timedelta_string_validator],
40    )
41
42    auth_session_duration = models.TextField(
43        default="hours=8", validators=[timedelta_string_validator]
44    )
45    auth_terminate_session_on_expiry = models.BooleanField(default=False)
46    authorization_flow = models.ForeignKey(
47        "authentik_flows.Flow", null=True, on_delete=models.SET_DEFAULT, default=None
48    )
49    jwt_federation_providers = models.ManyToManyField(
50        "authentik_providers_oauth2.OAuth2Provider",
51        blank=True,
52        default=None,
53        through="AgentConnectorJWTFederationProvider",
54    )
55
56    nss_uid_offset = models.PositiveIntegerField(default=1000)
57    nss_gid_offset = models.PositiveIntegerField(default=1000)
58
59    challenge_key = models.ForeignKey(CertificateKeyPair, on_delete=models.CASCADE, null=True)
60    challenge_idle_timeout = models.TextField(
61        validators=[timedelta_string_validator], default="seconds=5"
62    )
63    challenge_trigger_check_in = models.BooleanField(default=False)
64
65    @property
66    def icon_url(self):
67        return static("dist/assets/icons/icon.svg")
68
69    @property
70    def serializer(self) -> type[Serializer]:
71        from authentik.endpoints.connectors.agent.api.connectors import (
72            AgentConnectorSerializer,
73        )
74
75        return AgentConnectorSerializer
76
77    @property
78    def stage(self) -> type[StageView] | None:
79        from authentik.endpoints.connectors.agent.stage import (
80            AuthenticatorEndpointStageView,
81        )
82
83        return AuthenticatorEndpointStageView
84
85    @property
86    def controller(self) -> type[AgentConnectorController]:
87        from authentik.endpoints.connectors.agent.controller import AgentConnectorController
88
89        return AgentConnectorController
90
91    @property
92    def component(self) -> str:
93        return "ak-endpoints-connector-agent-form"
94
95    class Meta:
96        verbose_name = _("Agent Connector")
97        verbose_name_plural = _("Agent Connectors")

Configure authentication and add device compliance using the authentik Agent.

def refresh_interval(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def auth_session_duration(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def auth_terminate_session_on_expiry(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

authorization_flow

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.

jwt_federation_providers

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.

def nss_uid_offset(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def nss_gid_offset(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

challenge_key

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.

def challenge_idle_timeout(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def challenge_trigger_check_in(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

icon_url
65    @property
66    def icon_url(self):
67        return static("dist/assets/icons/icon.svg")
serializer: type[rest_framework.serializers.Serializer]
69    @property
70    def serializer(self) -> type[Serializer]:
71        from authentik.endpoints.connectors.agent.api.connectors import (
72            AgentConnectorSerializer,
73        )
74
75        return AgentConnectorSerializer

Get serializer for this model

stage: type[authentik.flows.stage.StageView] | None
77    @property
78    def stage(self) -> type[StageView] | None:
79        from authentik.endpoints.connectors.agent.stage import (
80            AuthenticatorEndpointStageView,
81        )
82
83        return AuthenticatorEndpointStageView
controller
85    @property
86    def controller(self) -> type[AgentConnectorController]:
87        from authentik.endpoints.connectors.agent.controller import AgentConnectorController
88
89        return AgentConnectorController
component: str
91    @property
92    def component(self) -> str:
93        return "ak-endpoints-connector-agent-form"
schedules

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example::

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

tasks

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example::

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

authorization_flow_id
challenge_key_id
connector_ptr_id
connector_ptr

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.

agentconnectorjwtfederationprovider_set

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.

enrollmenttoken_set

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.

deviceauthenticationtoken_set

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.

appleauthorizationcode_set

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.

class AgentConnector.DoesNotExist(authentik.endpoints.models.Connector.DoesNotExist):

The requested object does not exist

class AgentConnector.MultipleObjectsReturned(authentik.endpoints.models.Connector.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

class AgentConnectorJWTFederationProvider(authentik.lib.models.SimpleThroughModel):
100class AgentConnectorJWTFederationProvider(SimpleThroughModel):
101    agent_connector = models.ForeignKey(
102        AgentConnector, on_delete=models.CASCADE, db_column="agentconnector_id"
103    )
104    oauth2_provider = models.ForeignKey(
105        "authentik_providers_oauth2.OAuth2Provider",
106        on_delete=models.CASCADE,
107        db_column="oauth2provider_id",
108    )
109
110    class Meta:
111        db_table = "authentik_endpoints_connectors_agent_agentconnector_jwt_fed2bc6"
112        unique_together = (("agent_connector", "oauth2_provider"),)
113        verbose_name = _("Agent Connector JWT Federation Provider")
114        verbose_name_plural = _("Agent Connector JWT Federation Providers")
115
116    def __str__(self):
117        return (
118            f"AgentConnectorJWTFederationProvider for AgentConnector {self.agent_connector_id} "
119            f"and OAuth2Provider {self.oauth2_provider_id}."
120        )

AgentConnectorJWTFederationProvider(id, agent_connector, oauth2_provider)

agent_connector

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.

oauth2_provider

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.

agent_connector_id
oauth2_provider_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def objects(unknown):

The type of the None singleton.

class AgentConnectorJWTFederationProvider.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class AgentConnectorJWTFederationProvider.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

class AgentDeviceConnection(authentik.endpoints.models.DeviceConnection):
123class AgentDeviceConnection(DeviceConnection):
124
125    apple_key_exchange_key = models.TextField()
126    apple_encryption_key = models.TextField()
127    apple_enc_key_id = models.TextField()
128    apple_signing_key = models.TextField()
129    apple_sign_key_id = models.TextField()

AgentDeviceConnection(device_connection_uuid, device, connector, deviceconnection_ptr, apple_key_exchange_key, apple_encryption_key, apple_enc_key_id, apple_signing_key, apple_sign_key_id)

def apple_key_exchange_key(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def apple_encryption_key(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def apple_enc_key_id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def apple_signing_key(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def apple_sign_key_id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deviceconnection_ptr_id
deviceconnection_ptr

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.

devicetoken_set

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.

appleauthorizationcode_set

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.

class AgentDeviceConnection.DoesNotExist(authentik.endpoints.models.DeviceConnection.DoesNotExist):

The requested object does not exist

class AgentDeviceConnection.MultipleObjectsReturned(authentik.endpoints.models.DeviceConnection.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

class AgentDeviceUserBinding(authentik.endpoints.models.DeviceUserBinding):
132class AgentDeviceUserBinding(DeviceUserBinding):
133
134    apple_secure_enclave_key = models.TextField()
135    apple_enclave_key_id = models.TextField()
136
137    class Meta:
138        verbose_name = _("Agent Device User binding")
139        verbose_name_plural = _("Agent Device User bindings")

AgentDeviceUserBinding(expires, policy_binding_uuid, enabled, dry_run, expiring, policy, group, user, target, negate, timeout, failure_result, order, policybinding_ptr, is_primary, connector, deviceuserbinding_ptr, apple_secure_enclave_key, apple_enclave_key_id)

def apple_secure_enclave_key(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def apple_enclave_key_id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deviceuserbinding_ptr_id
deviceuserbinding_ptr

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.

appleunlockkey_set

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.

class AgentDeviceUserBinding.DoesNotExist(authentik.endpoints.models.DeviceUserBinding.DoesNotExist):

The requested object does not exist

class AgentDeviceUserBinding.MultipleObjectsReturned(authentik.endpoints.models.DeviceUserBinding.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

142class DeviceToken(InternallyManagedMixin, ExpiringModel):
143    """Per-device token used for authentication."""
144
145    token_uuid = models.UUIDField(primary_key=True, default=uuid4)
146    device = models.ForeignKey(AgentDeviceConnection, on_delete=models.CASCADE)
147    key = models.TextField(default=generate_key)
148
149    class Meta:
150        verbose_name = _("Device Token")
151        verbose_name_plural = _("Device Tokens")
152        indexes = ExpiringModel.Meta.indexes + [
153            models.Index(fields=["key"]),
154        ]

Per-device token used for authentication.

def token_uuid(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

device

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.

def key(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expires(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expiring(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

device_id
deviceauthenticationtoken_set

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.

applenonce_set

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.

class DeviceToken.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class DeviceToken.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

157class EnrollmentToken(ExpiringModel, SerializerModel):
158    """Token used during enrollment, a device will receive
159    a device token for further authentication"""
160
161    token_uuid = models.UUIDField(primary_key=True, editable=False, default=uuid4)
162    name = models.TextField()
163    key = models.TextField(default=default_token_key)
164    connector = models.ForeignKey(AgentConnector, on_delete=models.CASCADE)
165    device_group = models.ForeignKey(
166        DeviceAccessGroup, on_delete=models.SET_DEFAULT, default=None, null=True
167    )
168
169    @property
170    def serializer(self) -> type[Serializer]:
171        from authentik.endpoints.connectors.agent.api.enrollment_tokens import (
172            EnrollmentTokenSerializer,
173        )
174
175        return EnrollmentTokenSerializer
176
177    class Meta:
178        verbose_name = _("Enrollment Token")
179        verbose_name_plural = _("Enrollment Tokens")
180        indexes = ExpiringModel.Meta.indexes + [
181            models.Index(fields=["key"]),
182        ]
183        permissions = [
184            ("view_enrollment_token_key", _("View token's key")),
185        ]

Token used during enrollment, a device will receive a device token for further authentication

def token_uuid(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def name(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def key(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

connector

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.

device_group

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.

serializer: type[rest_framework.serializers.Serializer]
169    @property
170    def serializer(self) -> type[Serializer]:
171        from authentik.endpoints.connectors.agent.api.enrollment_tokens import (
172            EnrollmentTokenSerializer,
173        )
174
175        return EnrollmentTokenSerializer

Get serializer for this model

def expires(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expiring(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

connector_id
device_group_id
class EnrollmentToken.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class EnrollmentToken.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

188class DeviceAuthenticationToken(InternallyManagedMixin, ExpiringModel):
189
190    identifier = models.UUIDField(default=uuid4, primary_key=True)
191    device = models.ForeignKey(Device, on_delete=models.CASCADE)
192    device_token = models.ForeignKey(DeviceToken, on_delete=models.CASCADE)
193    connector = models.ForeignKey(AgentConnector, on_delete=models.CASCADE)
194    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, default=None)
195    token = models.TextField()
196
197    def __str__(self):
198        return f"Device authentication token {self.identifier}"
199
200    class Meta(ExpiringModel.Meta):
201        verbose_name = _("Device authentication token")
202        verbose_name_plural = _("Device authentication tokens")

DeviceAuthenticationToken(expires, expiring, identifier, device, device_token, connector, user, token)

def identifier(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

device

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.

device_token

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.

connector

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.

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.

def token(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expires(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expiring(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

device_id
device_token_id
connector_id
user_id
class DeviceAuthenticationToken.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class DeviceAuthenticationToken.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

205class AppleNonce(InternallyManagedMixin, ExpiringModel):
206    nonce = models.TextField()
207    device_token = models.ForeignKey(DeviceToken, on_delete=models.CASCADE)
208
209    class Meta(ExpiringModel.Meta):
210        verbose_name = _("Apple Nonce")
211        verbose_name_plural = _("Apple Nonces")

AppleNonce(id, expires, expiring, nonce, device_token)

def nonce(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

device_token

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.

def expires(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expiring(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

device_token_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class AppleNonce.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class AppleNonce.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

214class AppleAuthorizationCode(InternallyManagedMixin, ExpiringModel):
215    """Short-lived code issued by the authorize endpoint, exchanged for tokens."""
216
217    code = models.TextField(default=generate_id)
218    user = models.ForeignKey(User, on_delete=models.CASCADE)
219    connector = models.ForeignKey("AgentConnector", on_delete=models.CASCADE)
220    # The device the code was issued to, it is the only one allowed to redeem it
221    device_connection = models.ForeignKey(AgentDeviceConnection, on_delete=models.CASCADE)
222    state = models.TextField(default="")
223    scope = models.TextField()
224
225    class Meta(ExpiringModel.Meta):
226        verbose_name = _("Apple Authorization Code")
227        verbose_name_plural = _("Apple Authorization Codes")
228        indexes = ExpiringModel.Meta.indexes + [
229            models.Index(fields=["code"]),
230        ]

Short-lived code issued by the authorize endpoint, exchanged for tokens.

def code(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

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.

connector

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.

device_connection

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.

def state(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def scope(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expires(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expiring(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user_id
connector_id
device_connection_id
def id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class AppleAuthorizationCode.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class AppleAuthorizationCode.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

233class AppleUnlockKey(InternallyManagedMixin, ExpiringModel):
234    """Server-provisioned EC256 key for Platform SSO v2.0 user_unlock."""
235
236    identifier = models.UUIDField(primary_key=True, default=uuid4)
237    device_user = models.ForeignKey(AgentDeviceUserBinding, on_delete=models.CASCADE)
238    private_key = models.TextField()
239    certificate_der = models.TextField(default="")
240
241    class Meta(ExpiringModel.Meta):
242        verbose_name = _("Apple Unlock Key")
243        verbose_name_plural = _("Apple Unlock Keys")

Server-provisioned EC256 key for Platform SSO v2.0 user_unlock.

def identifier(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

device_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.

def private_key(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def certificate_der(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expires(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def expiring(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

device_user_id
class AppleUnlockKey.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class AppleUnlockKey.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.

class AppleIndependentSecureEnclave(authentik.stages.authenticator.models.Device):
246class AppleIndependentSecureEnclave(Authenticator):
247    """A device-independent secure enclave key, used by Tap-to-login"""
248
249    uuid = models.UUIDField(primary_key=True, default=uuid4)
250
251    apple_secure_enclave_key = models.TextField()
252    apple_enclave_key_id = models.TextField()
253    device_type = models.TextField()
254
255    class Meta:
256        verbose_name = _("Apple Independent Secure Enclave")
257        verbose_name_plural = _("Apple Independent Secure Enclaves")

A device-independent secure enclave key, used by Tap-to-login

def uuid(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def apple_secure_enclave_key(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def apple_enclave_key_id(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def device_type(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

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.

def name(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def confirmed(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def last_used(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def created(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def last_updated(unknown):

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

def get_next_by_created(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_created(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_next_by_last_updated(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

def get_previous_by_last_updated(unknown):

Method descriptor with partial application of the given arguments and keywords.

Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.

user_id
class AppleIndependentSecureEnclave.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

class AppleIndependentSecureEnclave.MultipleObjectsReturned(django.core.exceptions.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.