authentik.providers.saml.models
authentik SAML Provider Models
1"""authentik SAML Provider Models""" 2 3from uuid import uuid4 4 5from django.db import models 6from django.templatetags.static import static 7from django.urls import reverse 8from django.utils.translation import gettext_lazy as _ 9from rest_framework.serializers import Serializer 10from structlog.stdlib import get_logger 11 12from authentik.common.saml.constants import ( 13 AES128_CBC, 14 AES128_GCM, 15 AES256_CBC, 16 AES256_GCM, 17 DSA_SHA1, 18 ECDSA_SHA1, 19 ECDSA_SHA256, 20 ECDSA_SHA384, 21 ECDSA_SHA512, 22 RSA_SHA1, 23 RSA_SHA256, 24 RSA_SHA384, 25 RSA_SHA512, 26 SAML_BINDING_POST, 27 SAML_BINDING_REDIRECT, 28 SHA1, 29 SHA256, 30 SHA384, 31 SHA512, 32) 33from authentik.core.api.object_types import CreatableType 34from authentik.core.models import ( 35 AuthenticatedSession, 36 PropertyMapping, 37 Provider, 38 User, 39) 40from authentik.crypto.models import CertificateKeyPair 41from authentik.lib.models import ( 42 DomainlessURLValidator, 43 ExpiringModel, 44 InternallyManagedMixin, 45 SerializerModel, 46 SimpleThroughModel, 47) 48from authentik.lib.utils.time import timedelta_string_validator 49from authentik.sources.saml.models import SAMLNameIDPolicy 50 51LOGGER = get_logger() 52 53 54class SAMLBindings(models.TextChoices): 55 """SAML Bindings supported by authentik""" 56 57 REDIRECT = "redirect" 58 POST = "post" 59 60 @classmethod 61 def from_metadata_binding(cls, binding: str | None) -> SAMLBindings | None: 62 """Get the binding matching the `Binding` attribute `binding` of an endpoint in 63 SAML metadata, returns None for bindings authentik doesn't support.""" 64 return { 65 SAML_BINDING_REDIRECT: cls.REDIRECT, 66 SAML_BINDING_POST: cls.POST, 67 }.get(binding) 68 69 70class SAMLLogoutMethods(models.TextChoices): 71 """SAML Logout methods supported by authentik""" 72 73 FRONTCHANNEL_IFRAME = "frontchannel_iframe" 74 FRONTCHANNEL_NATIVE = "frontchannel_native" 75 BACKCHANNEL = "backchannel" 76 77 78class SAMLProvider(Provider): 79 """SAML 2.0 Endpoint for applications which support SAML.""" 80 81 acs_url = models.TextField( 82 validators=[DomainlessURLValidator(schemes=("http", "https"))], verbose_name=_("ACS URL") 83 ) 84 sp_binding = models.TextField( 85 choices=SAMLBindings.choices, 86 default=SAMLBindings.REDIRECT, 87 verbose_name=_("Service Provider Binding"), 88 help_text=_( 89 "This determines how authentik sends the response back to the Service Provider." 90 ), 91 ) 92 audience = models.TextField( 93 default="", 94 blank=True, 95 help_text=_( 96 "Value of the audience restriction field of the assertion. When left empty, " 97 "no audience restriction will be added." 98 ), 99 ) 100 issuer_override = models.TextField( 101 blank=True, 102 default="", 103 help_text=_( 104 "Also known as EntityID. Providing a value overrides the default issuer " 105 "generated by authentik." 106 ), 107 ) 108 sls_url = models.TextField( 109 blank=True, 110 validators=[DomainlessURLValidator(schemes=("http", "https"))], 111 verbose_name=_("SLS URL"), 112 help_text=_("Single Logout Service URL where the logout response should be sent."), 113 ) 114 sls_binding = models.TextField( 115 choices=SAMLBindings.choices, 116 default=SAMLBindings.REDIRECT, 117 verbose_name=_("SLS Binding"), 118 help_text=_( 119 "This determines how authentik sends the logout response back to the Service Provider." 120 ), 121 ) 122 logout_method = models.TextField( 123 choices=SAMLLogoutMethods.choices, 124 default=SAMLLogoutMethods.FRONTCHANNEL_IFRAME, 125 help_text=_( 126 "Method to use for logout. Front-channel iframe loads all logout URLs simultaneously " 127 "in hidden iframes. Front-channel native uses your active browser tab to send post " 128 "requests and redirect to providers. " 129 "Back-channel sends logout requests directly from the server without " 130 "user interaction (requires POST SLS binding)." 131 ), 132 ) 133 name_id_mapping = models.ForeignKey( 134 "SAMLPropertyMapping", 135 default=None, 136 blank=True, 137 null=True, 138 on_delete=models.SET_DEFAULT, 139 verbose_name=_("NameID Property Mapping"), 140 help_text=_( 141 "Configure how the NameID value will be created. When left empty, " 142 "the NameIDPolicy of the incoming request will be considered" 143 ), 144 ) 145 authn_context_class_ref_mapping = models.ForeignKey( 146 "SAMLPropertyMapping", 147 default=None, 148 blank=True, 149 null=True, 150 on_delete=models.SET_DEFAULT, 151 verbose_name=_("AuthnContextClassRef Property Mapping"), 152 related_name="+", 153 help_text=_( 154 "Configure how the AuthnContextClassRef value will be created. When left empty, " 155 "the AuthnContextClassRef will be set based on which authentication methods the user " 156 "used to authenticate." 157 ), 158 ) 159 160 assertion_valid_not_before = models.TextField( 161 default="minutes=-5", 162 validators=[timedelta_string_validator], 163 help_text=_( 164 "Assertion valid not before current time + this value " 165 "(Format: hours=-1;minutes=-2;seconds=-3)." 166 ), 167 ) 168 assertion_valid_not_on_or_after = models.TextField( 169 default="minutes=5", 170 validators=[timedelta_string_validator], 171 help_text=_( 172 "Assertion not valid on or after current time + this value " 173 "(Format: hours=1;minutes=2;seconds=3)." 174 ), 175 ) 176 177 session_valid_not_on_or_after = models.TextField( 178 default="minutes=86400", 179 validators=[timedelta_string_validator], 180 help_text=_( 181 "Session not valid on or after current time + this value " 182 "(Format: hours=1;minutes=2;seconds=3)." 183 ), 184 ) 185 186 digest_algorithm = models.TextField( 187 choices=( 188 (SHA1, _("SHA1")), 189 (SHA256, _("SHA256")), 190 (SHA384, _("SHA384")), 191 (SHA512, _("SHA512")), 192 ), 193 default=SHA256, 194 ) 195 signature_algorithm = models.TextField( 196 choices=( 197 (RSA_SHA1, _("RSA-SHA1")), 198 (RSA_SHA256, _("RSA-SHA256")), 199 (RSA_SHA384, _("RSA-SHA384")), 200 (RSA_SHA512, _("RSA-SHA512")), 201 (ECDSA_SHA1, _("ECDSA-SHA1")), 202 (ECDSA_SHA256, _("ECDSA-SHA256")), 203 (ECDSA_SHA384, _("ECDSA-SHA384")), 204 (ECDSA_SHA512, _("ECDSA-SHA512")), 205 (DSA_SHA1, _("DSA-SHA1")), 206 ), 207 default=RSA_SHA256, 208 ) 209 210 verification_kp = models.ForeignKey( 211 CertificateKeyPair, 212 default=None, 213 null=True, 214 blank=True, 215 help_text=_( 216 "When selected, incoming assertion's Signatures will be validated against this " 217 "certificate. To allow unsigned Requests, leave on default." 218 ), 219 on_delete=models.SET_NULL, 220 verbose_name=_("Verification Certificate"), 221 related_name="+", 222 ) 223 signing_kp = models.ForeignKey( 224 CertificateKeyPair, 225 default=None, 226 null=True, 227 blank=True, 228 help_text=_("Keypair used to sign outgoing Responses going to the Service Provider."), 229 on_delete=models.SET_NULL, 230 verbose_name=_("Signing Keypair"), 231 ) 232 encryption_kp = models.ForeignKey( 233 CertificateKeyPair, 234 default=None, 235 null=True, 236 blank=True, 237 help_text=_( 238 "When selected, incoming assertions are encrypted by the IdP using the public " 239 "key of the encryption keypair. The assertion is decrypted by the SP using the " 240 "the private key." 241 ), 242 on_delete=models.SET_NULL, 243 verbose_name=_("Encryption Keypair"), 244 related_name="+", 245 ) 246 encryption_algorithm = models.TextField( 247 choices=( 248 (AES128_CBC, _("AES128-CBC")), 249 (AES256_CBC, _("AES256-CBC")), 250 (AES128_GCM, _("AES128-GCM")), 251 (AES256_GCM, _("AES256-GCM")), 252 ), 253 default=AES256_GCM, 254 help_text=_("Block cipher used to encrypt the assertion."), 255 ) 256 257 default_relay_state = models.TextField( 258 default="", blank=True, help_text=_("Default relay_state value for IDP-initiated logins") 259 ) 260 default_name_id_policy = models.TextField( 261 choices=SAMLNameIDPolicy.choices, default=SAMLNameIDPolicy.UNSPECIFIED 262 ) 263 264 sign_assertion = models.BooleanField(default=True) 265 sign_response = models.BooleanField(default=False) 266 sign_logout_request = models.BooleanField(default=False) 267 sign_logout_response = models.BooleanField(default=False) 268 269 ignore_force_authn = models.BooleanField( 270 default=False, 271 db_default=False, 272 help_text=_( 273 "When enabled, the ForceAuthn attribute set by the Service Provider on an " 274 "AuthnRequest is ignored and an existing session is used. When disabled, " 275 "ForceAuthn requires the user to re-authenticate." 276 ), 277 ) 278 279 jwt_federation_providers = models.ManyToManyField( 280 "authentik_providers_oauth2.OAuth2Provider", 281 blank=True, 282 default=None, 283 related_name="saml_federation_providers", 284 through="SAMLProviderJWTFederationProvider", 285 help_text=_( 286 "OAuth2 providers which can exchange their JWTs for a SAML Response " 287 "of this provider via token exchange." 288 ), 289 ) 290 291 @property 292 def launch_url(self) -> str | None: 293 """Use IDP-Initiated SAML flow as launch URL""" 294 try: 295 return reverse( 296 "authentik_providers_saml:init", 297 kwargs={"application_slug": self.application.slug}, 298 ) 299 except Provider.application.RelatedObjectDoesNotExist: 300 return None 301 302 @property 303 def icon_url(self) -> str | None: 304 return static("authentik/sources/saml/light.png") 305 306 @property 307 def serializer(self) -> type[Serializer]: 308 from authentik.providers.saml.api.providers import SAMLProviderSerializer 309 310 return SAMLProviderSerializer 311 312 @property 313 def component(self) -> str: 314 return "ak-provider-saml-form" 315 316 def __str__(self): 317 return f"SAML Provider {self.name}" 318 319 class Meta: 320 verbose_name = _("SAML Provider") 321 verbose_name_plural = _("SAML Providers") 322 323 324class SAMLProviderJWTFederationProvider(SimpleThroughModel): 325 saml_provider = models.ForeignKey(SAMLProvider, on_delete=models.CASCADE) 326 oauth2_provider = models.ForeignKey( 327 "authentik_providers_oauth2.OAuth2Provider", on_delete=models.CASCADE 328 ) 329 330 class Meta: 331 unique_together = (("saml_provider", "oauth2_provider"),) 332 verbose_name = _("SAML Provider JWT Federation Provider") 333 verbose_name_plural = _("SAML Provider JWT Federation Providers") 334 335 def __str__(self): 336 return ( 337 f"SAMLProviderJWTFederationProvider for SAMLProvider {self.saml_provider_id} " 338 f"and OAuth2Provider {self.oauth2_provider_id}." 339 ) 340 341 342class SAMLPropertyMapping(PropertyMapping): 343 """Map User/Group attribute to SAML Attribute, which can be used by the Service Provider""" 344 345 saml_name = models.TextField(verbose_name="SAML Name") 346 friendly_name = models.TextField(default=None, blank=True, null=True) 347 348 @property 349 def component(self) -> str: 350 return "ak-property-mapping-provider-saml-form" 351 352 @property 353 def serializer(self) -> type[Serializer]: 354 from authentik.providers.saml.api.property_mappings import SAMLPropertyMappingSerializer 355 356 return SAMLPropertyMappingSerializer 357 358 def __str__(self): 359 name = self.friendly_name if self.friendly_name != "" else self.saml_name 360 return f"{self.name} ({name})" 361 362 class Meta: 363 verbose_name = _("SAML Provider Property Mapping") 364 verbose_name_plural = _("SAML Provider Property Mappings") 365 366 367class SAMLProviderImportModel(CreatableType, Provider): 368 """Create a SAML Provider by importing its Metadata.""" 369 370 @property 371 def component(self): 372 return "ak-provider-saml-import-form" 373 374 @property 375 def icon_url(self) -> str | None: 376 return static("authentik/sources/saml/light.png") 377 378 class Meta: 379 abstract = True 380 verbose_name = _("SAML Provider from Metadata") 381 verbose_name_plural = _("SAML Providers from Metadata") 382 383 384class SAMLSession(InternallyManagedMixin, SerializerModel, ExpiringModel): 385 """Track active SAML sessions for Single Logout support""" 386 387 saml_session_id = models.UUIDField(default=uuid4, primary_key=True) 388 provider = models.ForeignKey(SAMLProvider, on_delete=models.CASCADE) 389 user = models.ForeignKey(User, verbose_name=_("User"), on_delete=models.CASCADE) 390 session = models.ForeignKey( 391 AuthenticatedSession, 392 on_delete=models.CASCADE, 393 help_text=_("Link to the user's authenticated session"), 394 ) 395 session_index = models.TextField(help_text=_("SAML SessionIndex for this session")) 396 name_id = models.TextField(help_text=_("SAML NameID value for this session")) 397 name_id_format = models.TextField(default="", blank=True, help_text=_("SAML NameID format")) 398 issuer = models.TextField( 399 default=None, null=True, help_text=_("SAML Issuer used for this session") 400 ) 401 created = models.DateTimeField(auto_now_add=True) 402 403 @property 404 def serializer(self) -> type[Serializer]: 405 from authentik.providers.saml.api.sessions import SAMLSessionSerializer 406 407 return SAMLSessionSerializer 408 409 def __str__(self): 410 return f"SAML Session for provider {self.provider_id} and user {self.user_id}" 411 412 class Meta: 413 verbose_name = _("SAML Session") 414 verbose_name_plural = _("SAML Sessions") 415 unique_together = [("session_index", "provider")] 416 indexes = ExpiringModel.Meta.indexes + [ 417 models.Index(fields=["session_index"]), 418 models.Index(fields=["provider", "user"]), 419 models.Index(fields=["session"]), 420 ]
55class SAMLBindings(models.TextChoices): 56 """SAML Bindings supported by authentik""" 57 58 REDIRECT = "redirect" 59 POST = "post" 60 61 @classmethod 62 def from_metadata_binding(cls, binding: str | None) -> SAMLBindings | None: 63 """Get the binding matching the `Binding` attribute `binding` of an endpoint in 64 SAML metadata, returns None for bindings authentik doesn't support.""" 65 return { 66 SAML_BINDING_REDIRECT: cls.REDIRECT, 67 SAML_BINDING_POST: cls.POST, 68 }.get(binding)
SAML Bindings supported by authentik
61 @classmethod 62 def from_metadata_binding(cls, binding: str | None) -> SAMLBindings | None: 63 """Get the binding matching the `Binding` attribute `binding` of an endpoint in 64 SAML metadata, returns None for bindings authentik doesn't support.""" 65 return { 66 SAML_BINDING_REDIRECT: cls.REDIRECT, 67 SAML_BINDING_POST: cls.POST, 68 }.get(binding)
Get the binding matching the Binding attribute binding of an endpoint in
SAML metadata, returns None for bindings authentik doesn't support.
71class SAMLLogoutMethods(models.TextChoices): 72 """SAML Logout methods supported by authentik""" 73 74 FRONTCHANNEL_IFRAME = "frontchannel_iframe" 75 FRONTCHANNEL_NATIVE = "frontchannel_native" 76 BACKCHANNEL = "backchannel"
SAML Logout methods supported by authentik
79class SAMLProvider(Provider): 80 """SAML 2.0 Endpoint for applications which support SAML.""" 81 82 acs_url = models.TextField( 83 validators=[DomainlessURLValidator(schemes=("http", "https"))], verbose_name=_("ACS URL") 84 ) 85 sp_binding = models.TextField( 86 choices=SAMLBindings.choices, 87 default=SAMLBindings.REDIRECT, 88 verbose_name=_("Service Provider Binding"), 89 help_text=_( 90 "This determines how authentik sends the response back to the Service Provider." 91 ), 92 ) 93 audience = models.TextField( 94 default="", 95 blank=True, 96 help_text=_( 97 "Value of the audience restriction field of the assertion. When left empty, " 98 "no audience restriction will be added." 99 ), 100 ) 101 issuer_override = models.TextField( 102 blank=True, 103 default="", 104 help_text=_( 105 "Also known as EntityID. Providing a value overrides the default issuer " 106 "generated by authentik." 107 ), 108 ) 109 sls_url = models.TextField( 110 blank=True, 111 validators=[DomainlessURLValidator(schemes=("http", "https"))], 112 verbose_name=_("SLS URL"), 113 help_text=_("Single Logout Service URL where the logout response should be sent."), 114 ) 115 sls_binding = models.TextField( 116 choices=SAMLBindings.choices, 117 default=SAMLBindings.REDIRECT, 118 verbose_name=_("SLS Binding"), 119 help_text=_( 120 "This determines how authentik sends the logout response back to the Service Provider." 121 ), 122 ) 123 logout_method = models.TextField( 124 choices=SAMLLogoutMethods.choices, 125 default=SAMLLogoutMethods.FRONTCHANNEL_IFRAME, 126 help_text=_( 127 "Method to use for logout. Front-channel iframe loads all logout URLs simultaneously " 128 "in hidden iframes. Front-channel native uses your active browser tab to send post " 129 "requests and redirect to providers. " 130 "Back-channel sends logout requests directly from the server without " 131 "user interaction (requires POST SLS binding)." 132 ), 133 ) 134 name_id_mapping = models.ForeignKey( 135 "SAMLPropertyMapping", 136 default=None, 137 blank=True, 138 null=True, 139 on_delete=models.SET_DEFAULT, 140 verbose_name=_("NameID Property Mapping"), 141 help_text=_( 142 "Configure how the NameID value will be created. When left empty, " 143 "the NameIDPolicy of the incoming request will be considered" 144 ), 145 ) 146 authn_context_class_ref_mapping = models.ForeignKey( 147 "SAMLPropertyMapping", 148 default=None, 149 blank=True, 150 null=True, 151 on_delete=models.SET_DEFAULT, 152 verbose_name=_("AuthnContextClassRef Property Mapping"), 153 related_name="+", 154 help_text=_( 155 "Configure how the AuthnContextClassRef value will be created. When left empty, " 156 "the AuthnContextClassRef will be set based on which authentication methods the user " 157 "used to authenticate." 158 ), 159 ) 160 161 assertion_valid_not_before = models.TextField( 162 default="minutes=-5", 163 validators=[timedelta_string_validator], 164 help_text=_( 165 "Assertion valid not before current time + this value " 166 "(Format: hours=-1;minutes=-2;seconds=-3)." 167 ), 168 ) 169 assertion_valid_not_on_or_after = models.TextField( 170 default="minutes=5", 171 validators=[timedelta_string_validator], 172 help_text=_( 173 "Assertion not valid on or after current time + this value " 174 "(Format: hours=1;minutes=2;seconds=3)." 175 ), 176 ) 177 178 session_valid_not_on_or_after = models.TextField( 179 default="minutes=86400", 180 validators=[timedelta_string_validator], 181 help_text=_( 182 "Session not valid on or after current time + this value " 183 "(Format: hours=1;minutes=2;seconds=3)." 184 ), 185 ) 186 187 digest_algorithm = models.TextField( 188 choices=( 189 (SHA1, _("SHA1")), 190 (SHA256, _("SHA256")), 191 (SHA384, _("SHA384")), 192 (SHA512, _("SHA512")), 193 ), 194 default=SHA256, 195 ) 196 signature_algorithm = models.TextField( 197 choices=( 198 (RSA_SHA1, _("RSA-SHA1")), 199 (RSA_SHA256, _("RSA-SHA256")), 200 (RSA_SHA384, _("RSA-SHA384")), 201 (RSA_SHA512, _("RSA-SHA512")), 202 (ECDSA_SHA1, _("ECDSA-SHA1")), 203 (ECDSA_SHA256, _("ECDSA-SHA256")), 204 (ECDSA_SHA384, _("ECDSA-SHA384")), 205 (ECDSA_SHA512, _("ECDSA-SHA512")), 206 (DSA_SHA1, _("DSA-SHA1")), 207 ), 208 default=RSA_SHA256, 209 ) 210 211 verification_kp = models.ForeignKey( 212 CertificateKeyPair, 213 default=None, 214 null=True, 215 blank=True, 216 help_text=_( 217 "When selected, incoming assertion's Signatures will be validated against this " 218 "certificate. To allow unsigned Requests, leave on default." 219 ), 220 on_delete=models.SET_NULL, 221 verbose_name=_("Verification Certificate"), 222 related_name="+", 223 ) 224 signing_kp = models.ForeignKey( 225 CertificateKeyPair, 226 default=None, 227 null=True, 228 blank=True, 229 help_text=_("Keypair used to sign outgoing Responses going to the Service Provider."), 230 on_delete=models.SET_NULL, 231 verbose_name=_("Signing Keypair"), 232 ) 233 encryption_kp = models.ForeignKey( 234 CertificateKeyPair, 235 default=None, 236 null=True, 237 blank=True, 238 help_text=_( 239 "When selected, incoming assertions are encrypted by the IdP using the public " 240 "key of the encryption keypair. The assertion is decrypted by the SP using the " 241 "the private key." 242 ), 243 on_delete=models.SET_NULL, 244 verbose_name=_("Encryption Keypair"), 245 related_name="+", 246 ) 247 encryption_algorithm = models.TextField( 248 choices=( 249 (AES128_CBC, _("AES128-CBC")), 250 (AES256_CBC, _("AES256-CBC")), 251 (AES128_GCM, _("AES128-GCM")), 252 (AES256_GCM, _("AES256-GCM")), 253 ), 254 default=AES256_GCM, 255 help_text=_("Block cipher used to encrypt the assertion."), 256 ) 257 258 default_relay_state = models.TextField( 259 default="", blank=True, help_text=_("Default relay_state value for IDP-initiated logins") 260 ) 261 default_name_id_policy = models.TextField( 262 choices=SAMLNameIDPolicy.choices, default=SAMLNameIDPolicy.UNSPECIFIED 263 ) 264 265 sign_assertion = models.BooleanField(default=True) 266 sign_response = models.BooleanField(default=False) 267 sign_logout_request = models.BooleanField(default=False) 268 sign_logout_response = models.BooleanField(default=False) 269 270 ignore_force_authn = models.BooleanField( 271 default=False, 272 db_default=False, 273 help_text=_( 274 "When enabled, the ForceAuthn attribute set by the Service Provider on an " 275 "AuthnRequest is ignored and an existing session is used. When disabled, " 276 "ForceAuthn requires the user to re-authenticate." 277 ), 278 ) 279 280 jwt_federation_providers = models.ManyToManyField( 281 "authentik_providers_oauth2.OAuth2Provider", 282 blank=True, 283 default=None, 284 related_name="saml_federation_providers", 285 through="SAMLProviderJWTFederationProvider", 286 help_text=_( 287 "OAuth2 providers which can exchange their JWTs for a SAML Response " 288 "of this provider via token exchange." 289 ), 290 ) 291 292 @property 293 def launch_url(self) -> str | None: 294 """Use IDP-Initiated SAML flow as launch URL""" 295 try: 296 return reverse( 297 "authentik_providers_saml:init", 298 kwargs={"application_slug": self.application.slug}, 299 ) 300 except Provider.application.RelatedObjectDoesNotExist: 301 return None 302 303 @property 304 def icon_url(self) -> str | None: 305 return static("authentik/sources/saml/light.png") 306 307 @property 308 def serializer(self) -> type[Serializer]: 309 from authentik.providers.saml.api.providers import SAMLProviderSerializer 310 311 return SAMLProviderSerializer 312 313 @property 314 def component(self) -> str: 315 return "ak-provider-saml-form" 316 317 def __str__(self): 318 return f"SAML Provider {self.name}" 319 320 class Meta: 321 verbose_name = _("SAML Provider") 322 verbose_name_plural = _("SAML Providers")
SAML 2.0 Endpoint for applications which support SAML.
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.
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.
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.
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.
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.
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.
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.
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 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.
292 @property 293 def launch_url(self) -> str | None: 294 """Use IDP-Initiated SAML flow as launch URL""" 295 try: 296 return reverse( 297 "authentik_providers_saml:init", 298 kwargs={"application_slug": self.application.slug}, 299 ) 300 except Provider.application.RelatedObjectDoesNotExist: 301 return None
Use IDP-Initiated SAML flow as launch URL
307 @property 308 def serializer(self) -> type[Serializer]: 309 from authentik.providers.saml.api.providers import SAMLProviderSerializer 310 311 return SAMLProviderSerializer
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.
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 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.
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.
Accessor to the related object on the reverse side of a one-to-one relation.
In the example::
class Restaurant(Model):
place = OneToOneField(Place, related_name='restaurant')
Place.restaurant is a ReverseOneToOneDescriptor instance.
Inherited Members
- authentik.core.models.Provider
- name
- authentication_flow
- invalidation_flow
- property_mappings
- backchannel_application
- is_backchannel
- objects
- authentication_flow_id
- invalidation_flow_id
- backchannel_application_id
- id
- application
- providerpropertymapping_set
- outpost_set
- outpostprovider_set
- oauth2provider
- ldapprovider
- racprovider
- radiusprovider
- samlprovider
- scimprovider
- googleworkspaceprovider
- microsoftentraprovider
- ssfprovider
The requested object does not exist
The query returned multiple objects when only one was expected.
325class SAMLProviderJWTFederationProvider(SimpleThroughModel): 326 saml_provider = models.ForeignKey(SAMLProvider, on_delete=models.CASCADE) 327 oauth2_provider = models.ForeignKey( 328 "authentik_providers_oauth2.OAuth2Provider", on_delete=models.CASCADE 329 ) 330 331 class Meta: 332 unique_together = (("saml_provider", "oauth2_provider"),) 333 verbose_name = _("SAML Provider JWT Federation Provider") 334 verbose_name_plural = _("SAML Provider JWT Federation Providers") 335 336 def __str__(self): 337 return ( 338 f"SAMLProviderJWTFederationProvider for SAMLProvider {self.saml_provider_id} " 339 f"and OAuth2Provider {self.oauth2_provider_id}." 340 )
SAMLProviderJWTFederationProvider(id, saml_provider, 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.
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.
343class SAMLPropertyMapping(PropertyMapping): 344 """Map User/Group attribute to SAML Attribute, which can be used by the Service Provider""" 345 346 saml_name = models.TextField(verbose_name="SAML Name") 347 friendly_name = models.TextField(default=None, blank=True, null=True) 348 349 @property 350 def component(self) -> str: 351 return "ak-property-mapping-provider-saml-form" 352 353 @property 354 def serializer(self) -> type[Serializer]: 355 from authentik.providers.saml.api.property_mappings import SAMLPropertyMappingSerializer 356 357 return SAMLPropertyMappingSerializer 358 359 def __str__(self): 360 name = self.friendly_name if self.friendly_name != "" else self.saml_name 361 return f"{self.name} ({name})" 362 363 class Meta: 364 verbose_name = _("SAML Provider Property Mapping") 365 verbose_name_plural = _("SAML Provider Property Mappings")
Map User/Group attribute to SAML Attribute, which can be used by the Service Provider
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.
353 @property 354 def serializer(self) -> type[Serializer]: 355 from authentik.providers.saml.api.property_mappings import SAMLPropertyMappingSerializer 356 357 return SAMLPropertyMappingSerializer
Get serializer for this model
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.core.models.PropertyMapping
- pm_uuid
- name
- expression
- objects
- expression_allowed_types
- evaluate
- managed
- provider_set
- source_userpropertymappings_set
- source_grouppropertymappings_set
- sourceuserpropertymapping_set
- sourcegrouppropertymapping_set
- providerpropertymapping_set
- notificationwebhookmapping
- kerberossourcepropertymapping
- ldapsourcepropertymapping
- oauthsourcepropertymapping
- scopemapping
- racpropertymapping
- radiusproviderpropertymapping
- samlsourcepropertymapping
- samlpropertymapping
- scimprovider_set
- scimprovidergrouppropertymapping_set
- scimmapping
- plexsourcepropertymapping
- scimsourcepropertymapping
- telegramsourcepropertymapping
- googleworkspaceprovider_set
- googleworkspaceproviderpropertymappingsgroup_set
- googleworkspaceprovidermapping
- microsoftentraprovider_set
- microsoftentraproviderpropertymappingsgroup_set
- microsoftentraprovidermapping
The requested object does not exist
The query returned multiple objects when only one was expected.
368class SAMLProviderImportModel(CreatableType, Provider): 369 """Create a SAML Provider by importing its Metadata.""" 370 371 @property 372 def component(self): 373 return "ak-provider-saml-import-form" 374 375 @property 376 def icon_url(self) -> str | None: 377 return static("authentik/sources/saml/light.png") 378 379 class Meta: 380 abstract = True 381 verbose_name = _("SAML Provider from Metadata") 382 verbose_name_plural = _("SAML Providers from Metadata")
Create a SAML Provider by importing its Metadata.
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.core.models.Provider
- name
- authentication_flow
- invalidation_flow
- property_mappings
- backchannel_application
- is_backchannel
- objects
- launch_url
- serializer
- DoesNotExist
- MultipleObjectsReturned
- authentication_flow_id
- invalidation_flow_id
- backchannel_application_id
- id
- application
- providerpropertymapping_set
- outpost_set
- outpostprovider_set
- oauth2provider
- ldapprovider
- racprovider
- radiusprovider
- samlprovider
- scimprovider
- googleworkspaceprovider
- microsoftentraprovider
- ssfprovider
385class SAMLSession(InternallyManagedMixin, SerializerModel, ExpiringModel): 386 """Track active SAML sessions for Single Logout support""" 387 388 saml_session_id = models.UUIDField(default=uuid4, primary_key=True) 389 provider = models.ForeignKey(SAMLProvider, on_delete=models.CASCADE) 390 user = models.ForeignKey(User, verbose_name=_("User"), on_delete=models.CASCADE) 391 session = models.ForeignKey( 392 AuthenticatedSession, 393 on_delete=models.CASCADE, 394 help_text=_("Link to the user's authenticated session"), 395 ) 396 session_index = models.TextField(help_text=_("SAML SessionIndex for this session")) 397 name_id = models.TextField(help_text=_("SAML NameID value for this session")) 398 name_id_format = models.TextField(default="", blank=True, help_text=_("SAML NameID format")) 399 issuer = models.TextField( 400 default=None, null=True, help_text=_("SAML Issuer used for this session") 401 ) 402 created = models.DateTimeField(auto_now_add=True) 403 404 @property 405 def serializer(self) -> type[Serializer]: 406 from authentik.providers.saml.api.sessions import SAMLSessionSerializer 407 408 return SAMLSessionSerializer 409 410 def __str__(self): 411 return f"SAML Session for provider {self.provider_id} and user {self.user_id}" 412 413 class Meta: 414 verbose_name = _("SAML Session") 415 verbose_name_plural = _("SAML Sessions") 416 unique_together = [("session_index", "provider")] 417 indexes = ExpiringModel.Meta.indexes + [ 418 models.Index(fields=["session_index"]), 419 models.Index(fields=["provider", "user"]), 420 models.Index(fields=["session"]), 421 ]
Track active SAML sessions for Single Logout support
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.
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.
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.
404 @property 405 def serializer(self) -> type[Serializer]: 406 from authentik.providers.saml.api.sessions import SAMLSessionSerializer 407 408 return SAMLSessionSerializer
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.
Method descriptor with partial application of the given arguments and keywords.
Supports wrapping existing descriptors and handles non-descriptor callables as instance methods.
The requested object does not exist
The query returned multiple objects when only one was expected.