authentik.enterprise.endpoints.connectors.microsoft_intune.models

 1from typing import TYPE_CHECKING
 2
 3from azure.identity import ClientSecretCredential
 4from django.db import models
 5from django.templatetags.static import static
 6from django.utils.translation import gettext_lazy as _
 7
 8from authentik.crypto.models import CertificateKeyPair
 9from authentik.endpoints.models import Connector
10from authentik.lib.models import SimpleThroughModel
11
12if TYPE_CHECKING:
13    from authentik.enterprise.endpoints.connectors.microsoft_intune.controller import (
14        MicrosoftIntuneController,
15    )
16
17
18class MicrosoftIntuneConnector(Connector):
19    """Sync device details from Microsoft Intune"""
20
21    client_id = models.TextField()
22    client_secret = models.TextField()
23    tenant_id = models.TextField()
24
25    certificate_authorities = models.ManyToManyField(
26        CertificateKeyPair,
27        default=None,
28        blank=True,
29        help_text=_(
30            "Certificate authorities which issue device certificates via Intune (Cloud PKI, "
31            "SCEP or PKCS profiles), used by the endpoint stage to validate certificates. "
32            "This option has a higher priority than the `client_certificate` option on `Brand`."
33        ),
34        through="MicrosoftIntuneConnectorCertificateAuthority",
35    )
36
37    def microsoft_credentials(self):
38        return {
39            "credentials": ClientSecretCredential(
40                self.tenant_id, self.client_id, self.client_secret
41            )
42        }
43
44    @property
45    def serializer(self):
46        from authentik.enterprise.endpoints.connectors.microsoft_intune.api import (
47            MicrosoftIntuneConnectorSerializer,
48        )
49
50        return MicrosoftIntuneConnectorSerializer
51
52    @property
53    def controller(self) -> type[MicrosoftIntuneController]:
54        from authentik.enterprise.endpoints.connectors.microsoft_intune.controller import (
55            MicrosoftIntuneController,
56        )
57
58        return MicrosoftIntuneController
59
60    @property
61    def stage(self):
62        from authentik.enterprise.endpoints.connectors.microsoft_intune.stage import (
63            MicrosoftIntuneStageView,
64        )
65
66        return MicrosoftIntuneStageView
67
68    @property
69    def icon_url(self):
70        return static("authentik/sources/entraid.svg")
71
72    @property
73    def component(self) -> str:
74        return "ak-endpoints-connector-microsoft-intune-form"
75
76    class Meta:
77        verbose_name = _("Microsoft Intune Connector")
78        verbose_name_plural = _("Microsoft Intune Connectors")
79
80
81class MicrosoftIntuneConnectorCertificateAuthority(SimpleThroughModel):
82    connector = models.ForeignKey(MicrosoftIntuneConnector, on_delete=models.CASCADE)
83    certificate_key_pair = models.ForeignKey(CertificateKeyPair, on_delete=models.CASCADE)
84
85    class Meta:
86        unique_together = (("connector", "certificate_key_pair"),)
87        verbose_name = _("Microsoft Intune Connector Certificate Authority")
88        verbose_name_plural = _("Microsoft Intune Connector Certificate Authorities")
89
90    def __str__(self):
91        return (
92            "MicrosoftIntuneConnectorCertificateAuthority for MicrosoftIntuneConnector "
93            f"{self.connector_id} and CertificateKeyPair {self.certificate_key_pair_id}."
94        )
class MicrosoftIntuneConnector(authentik.endpoints.models.Connector):
19class MicrosoftIntuneConnector(Connector):
20    """Sync device details from Microsoft Intune"""
21
22    client_id = models.TextField()
23    client_secret = models.TextField()
24    tenant_id = models.TextField()
25
26    certificate_authorities = models.ManyToManyField(
27        CertificateKeyPair,
28        default=None,
29        blank=True,
30        help_text=_(
31            "Certificate authorities which issue device certificates via Intune (Cloud PKI, "
32            "SCEP or PKCS profiles), used by the endpoint stage to validate certificates. "
33            "This option has a higher priority than the `client_certificate` option on `Brand`."
34        ),
35        through="MicrosoftIntuneConnectorCertificateAuthority",
36    )
37
38    def microsoft_credentials(self):
39        return {
40            "credentials": ClientSecretCredential(
41                self.tenant_id, self.client_id, self.client_secret
42            )
43        }
44
45    @property
46    def serializer(self):
47        from authentik.enterprise.endpoints.connectors.microsoft_intune.api import (
48            MicrosoftIntuneConnectorSerializer,
49        )
50
51        return MicrosoftIntuneConnectorSerializer
52
53    @property
54    def controller(self) -> type[MicrosoftIntuneController]:
55        from authentik.enterprise.endpoints.connectors.microsoft_intune.controller import (
56            MicrosoftIntuneController,
57        )
58
59        return MicrosoftIntuneController
60
61    @property
62    def stage(self):
63        from authentik.enterprise.endpoints.connectors.microsoft_intune.stage import (
64            MicrosoftIntuneStageView,
65        )
66
67        return MicrosoftIntuneStageView
68
69    @property
70    def icon_url(self):
71        return static("authentik/sources/entraid.svg")
72
73    @property
74    def component(self) -> str:
75        return "ak-endpoints-connector-microsoft-intune-form"
76
77    class Meta:
78        verbose_name = _("Microsoft Intune Connector")
79        verbose_name_plural = _("Microsoft Intune Connectors")

Sync device details from Microsoft Intune

def client_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 client_secret(unknown):

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

def tenant_id(unknown):

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

certificate_authorities

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 microsoft_credentials(self):
38    def microsoft_credentials(self):
39        return {
40            "credentials": ClientSecretCredential(
41                self.tenant_id, self.client_id, self.client_secret
42            )
43        }
serializer
45    @property
46    def serializer(self):
47        from authentik.enterprise.endpoints.connectors.microsoft_intune.api import (
48            MicrosoftIntuneConnectorSerializer,
49        )
50
51        return MicrosoftIntuneConnectorSerializer

Get serializer for this model

controller
53    @property
54    def controller(self) -> type[MicrosoftIntuneController]:
55        from authentik.enterprise.endpoints.connectors.microsoft_intune.controller import (
56            MicrosoftIntuneController,
57        )
58
59        return MicrosoftIntuneController
stage
61    @property
62    def stage(self):
63        from authentik.enterprise.endpoints.connectors.microsoft_intune.stage import (
64            MicrosoftIntuneStageView,
65        )
66
67        return MicrosoftIntuneStageView
icon_url
69    @property
70    def icon_url(self):
71        return static("authentik/sources/entraid.svg")
component: str
73    @property
74    def component(self) -> str:
75        return "ak-endpoints-connector-microsoft-intune-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.

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.

microsoftintuneconnectorcertificateauthority_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 MicrosoftIntuneConnector.DoesNotExist(authentik.endpoints.models.Connector.DoesNotExist):

The requested object does not exist

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

The query returned multiple objects when only one was expected.

class MicrosoftIntuneConnectorCertificateAuthority(authentik.lib.models.SimpleThroughModel):
82class MicrosoftIntuneConnectorCertificateAuthority(SimpleThroughModel):
83    connector = models.ForeignKey(MicrosoftIntuneConnector, on_delete=models.CASCADE)
84    certificate_key_pair = models.ForeignKey(CertificateKeyPair, on_delete=models.CASCADE)
85
86    class Meta:
87        unique_together = (("connector", "certificate_key_pair"),)
88        verbose_name = _("Microsoft Intune Connector Certificate Authority")
89        verbose_name_plural = _("Microsoft Intune Connector Certificate Authorities")
90
91    def __str__(self):
92        return (
93            "MicrosoftIntuneConnectorCertificateAuthority for MicrosoftIntuneConnector "
94            f"{self.connector_id} and CertificateKeyPair {self.certificate_key_pair_id}."
95        )

MicrosoftIntuneConnectorCertificateAuthority(id, connector, certificate_key_pair)

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.

certificate_key_pair

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_id
certificate_key_pair_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 MicrosoftIntuneConnectorCertificateAuthority.DoesNotExist(django.core.exceptions.ObjectDoesNotExist):

The requested object does not exist

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

The query returned multiple objects when only one was expected.