authentik.enterprise.stages.mtls.models
1from django.db import models 2from django.utils.translation import gettext_lazy as _ 3from rest_framework.serializers import Serializer 4 5from authentik.crypto.models import CertificateKeyPair 6from authentik.endpoints.models import StageMode 7from authentik.flows.models import Stage 8from authentik.flows.stage import StageView 9from authentik.lib.models import SimpleThroughModel 10 11 12class CertAttributes(models.TextChoices): 13 """Certificate attribute used for user matching""" 14 15 SUBJECT = "subject" 16 COMMON_NAME = "common_name" 17 EMAIL = "email" 18 19 20class UserAttributes(models.TextChoices): 21 """User attribute for user matching""" 22 23 USERNAME = "username" 24 EMAIL = "email" 25 26 27class MutualTLSStage(Stage): 28 """Authenticate/enroll users using a client-certificate.""" 29 30 mode = models.TextField(choices=StageMode.choices) 31 32 certificate_authorities = models.ManyToManyField( 33 CertificateKeyPair, 34 default=None, 35 blank=True, 36 help_text=_( 37 "Configure certificate authorities to validate the certificate against. " 38 "This option has a higher priority than the `client_certificate` option on `Brand`." 39 ), 40 through="MutualTLSStageCertificateAuthority", 41 ) 42 43 cert_attribute = models.TextField(choices=CertAttributes.choices) 44 user_attribute = models.TextField(choices=UserAttributes.choices) 45 46 @property 47 def view(self) -> type[StageView]: 48 from authentik.enterprise.stages.mtls.stage import MTLSStageView 49 50 return MTLSStageView 51 52 @property 53 def serializer(self) -> type[Serializer]: 54 from authentik.enterprise.stages.mtls.api import MutualTLSStageSerializer 55 56 return MutualTLSStageSerializer 57 58 @property 59 def component(self) -> str: 60 return "ak-stage-mtls-form" 61 62 class Meta: 63 verbose_name = _("Mutual TLS Stage") 64 verbose_name_plural = _("Mutual TLS Stages") 65 permissions = [ 66 ("pass_outpost_certificate", _("Permissions to pass Certificates for outposts.")), 67 ] 68 69 70class MutualTLSStageCertificateAuthority(SimpleThroughModel): 71 mutual_tls_stage = models.ForeignKey( 72 MutualTLSStage, 73 on_delete=models.CASCADE, 74 db_column="mutualtlsstage_id", 75 ) 76 certificate_key_pair = models.ForeignKey( 77 CertificateKeyPair, on_delete=models.CASCADE, db_column="certificatekeypair_id" 78 ) 79 80 class Meta: 81 db_table = "authentik_stages_mtls_mutualtlsstage_certificate_authorities" 82 unique_together = (("mutual_tls_stage", "certificate_key_pair"),) 83 verbose_name = _("Mutual TLS Stage Certificate Authority") 84 verbose_name_plural = _("Mutual TLS Stage Certificate Authoritys") 85 86 def __str__(self): 87 return ( 88 "MutualTLSStageCertificateAuthority for MutualTLSStage " 89 f"{self.mutual_tls_stage_id} " 90 f"and CertificateKeyPair {self.certificate_key_pair_id}." 91 )
13class CertAttributes(models.TextChoices): 14 """Certificate attribute used for user matching""" 15 16 SUBJECT = "subject" 17 COMMON_NAME = "common_name" 18 EMAIL = "email"
Certificate attribute used for user matching
21class UserAttributes(models.TextChoices): 22 """User attribute for user matching""" 23 24 USERNAME = "username" 25 EMAIL = "email"
User attribute for user matching
28class MutualTLSStage(Stage): 29 """Authenticate/enroll users using a client-certificate.""" 30 31 mode = models.TextField(choices=StageMode.choices) 32 33 certificate_authorities = models.ManyToManyField( 34 CertificateKeyPair, 35 default=None, 36 blank=True, 37 help_text=_( 38 "Configure certificate authorities to validate the certificate against. " 39 "This option has a higher priority than the `client_certificate` option on `Brand`." 40 ), 41 through="MutualTLSStageCertificateAuthority", 42 ) 43 44 cert_attribute = models.TextField(choices=CertAttributes.choices) 45 user_attribute = models.TextField(choices=UserAttributes.choices) 46 47 @property 48 def view(self) -> type[StageView]: 49 from authentik.enterprise.stages.mtls.stage import MTLSStageView 50 51 return MTLSStageView 52 53 @property 54 def serializer(self) -> type[Serializer]: 55 from authentik.enterprise.stages.mtls.api import MutualTLSStageSerializer 56 57 return MutualTLSStageSerializer 58 59 @property 60 def component(self) -> str: 61 return "ak-stage-mtls-form" 62 63 class Meta: 64 verbose_name = _("Mutual TLS Stage") 65 verbose_name_plural = _("Mutual TLS Stages") 66 permissions = [ 67 ("pass_outpost_certificate", _("Permissions to pass Certificates for outposts.")), 68 ]
Authenticate/enroll users using a client-certificate.
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.
47 @property 48 def view(self) -> type[StageView]: 49 from authentik.enterprise.stages.mtls.stage import MTLSStageView 50 51 return MTLSStageView
Return StageView class that implements logic for this stage
53 @property 54 def serializer(self) -> type[Serializer]: 55 from authentik.enterprise.stages.mtls.api import MutualTLSStageSerializer 56 57 return MutualTLSStageSerializer
Get serializer for this model
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.
Inherited Members
- authentik.flows.models.Stage
- stage_uuid
- name
- objects
- ui_user_settings
- 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.
71class MutualTLSStageCertificateAuthority(SimpleThroughModel): 72 mutual_tls_stage = models.ForeignKey( 73 MutualTLSStage, 74 on_delete=models.CASCADE, 75 db_column="mutualtlsstage_id", 76 ) 77 certificate_key_pair = models.ForeignKey( 78 CertificateKeyPair, on_delete=models.CASCADE, db_column="certificatekeypair_id" 79 ) 80 81 class Meta: 82 db_table = "authentik_stages_mtls_mutualtlsstage_certificate_authorities" 83 unique_together = (("mutual_tls_stage", "certificate_key_pair"),) 84 verbose_name = _("Mutual TLS Stage Certificate Authority") 85 verbose_name_plural = _("Mutual TLS Stage Certificate Authoritys") 86 87 def __str__(self): 88 return ( 89 "MutualTLSStageCertificateAuthority for MutualTLSStage " 90 f"{self.mutual_tls_stage_id} " 91 f"and CertificateKeyPair {self.certificate_key_pair_id}." 92 )
MutualTLSStageCertificateAuthority(id, mutual_tls_stage, 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.
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.