authentik.enterprise.stages.source.models

Source stage models

 1"""Source stage models"""
 2
 3from django.contrib.postgres.fields import ArrayField
 4from django.db import models
 5from django.utils.translation import gettext_lazy as _
 6from django.views import View
 7from rest_framework.serializers import BaseSerializer
 8
 9from authentik.core.sources.matcher import MatchFailureReason
10from authentik.flows.models import Stage
11from authentik.lib.utils.time import timedelta_string_validator
12
13
14class SourceStage(Stage):
15    """Suspend the current flow execution and send the user to a federated source,
16    after which this flow execution is resumed."""
17
18    source = models.ForeignKey("authentik_core.Source", on_delete=models.CASCADE)
19
20    resume_timeout = models.TextField(
21        default="minutes=10",
22        validators=[timedelta_string_validator],
23        help_text=_(
24            "Amount of time a user can take to return from the source to continue the flow "
25            "(Format: hours=-1;minutes=-2;seconds=-3)"
26        ),
27    )
28
29    resume_on_match_failures = ArrayField(
30        models.TextField(choices=MatchFailureReason.choices),
31        default=list,
32        blank=True,
33        help_text=_("Source matching failure reasons for which the flow should resume."),
34    )
35
36    @property
37    def serializer(self) -> type[BaseSerializer]:
38        from authentik.enterprise.stages.source.api import SourceStageSerializer
39
40        return SourceStageSerializer
41
42    @property
43    def view(self) -> type[View]:
44        from authentik.enterprise.stages.source.stage import SourceStageView
45
46        return SourceStageView
47
48    @property
49    def component(self) -> str:
50        return "ak-stage-source-form"
51
52    class Meta:
53        verbose_name = _("Source Stage")
54        verbose_name_plural = _("Source Stages")
class SourceStage(authentik.flows.models.Stage):
15class SourceStage(Stage):
16    """Suspend the current flow execution and send the user to a federated source,
17    after which this flow execution is resumed."""
18
19    source = models.ForeignKey("authentik_core.Source", on_delete=models.CASCADE)
20
21    resume_timeout = models.TextField(
22        default="minutes=10",
23        validators=[timedelta_string_validator],
24        help_text=_(
25            "Amount of time a user can take to return from the source to continue the flow "
26            "(Format: hours=-1;minutes=-2;seconds=-3)"
27        ),
28    )
29
30    resume_on_match_failures = ArrayField(
31        models.TextField(choices=MatchFailureReason.choices),
32        default=list,
33        blank=True,
34        help_text=_("Source matching failure reasons for which the flow should resume."),
35    )
36
37    @property
38    def serializer(self) -> type[BaseSerializer]:
39        from authentik.enterprise.stages.source.api import SourceStageSerializer
40
41        return SourceStageSerializer
42
43    @property
44    def view(self) -> type[View]:
45        from authentik.enterprise.stages.source.stage import SourceStageView
46
47        return SourceStageView
48
49    @property
50    def component(self) -> str:
51        return "ak-stage-source-form"
52
53    class Meta:
54        verbose_name = _("Source Stage")
55        verbose_name_plural = _("Source Stages")

Suspend the current flow execution and send the user to a federated source, after which this flow execution is resumed.

source

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 resume_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 resume_on_match_failures(unknown):

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

serializer: type[rest_framework.serializers.BaseSerializer]
37    @property
38    def serializer(self) -> type[BaseSerializer]:
39        from authentik.enterprise.stages.source.api import SourceStageSerializer
40
41        return SourceStageSerializer

Get serializer for this model

view: type[django.views.generic.base.View]
43    @property
44    def view(self) -> type[View]:
45        from authentik.enterprise.stages.source.stage import SourceStageView
46
47        return SourceStageView

Return StageView class that implements logic for this stage

component: str
49    @property
50    def component(self) -> str:
51        return "ak-stage-source-form"

Return component used to edit this object

source_id
stage_ptr_id
stage_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.

class SourceStage.DoesNotExist(authentik.flows.models.Stage.DoesNotExist):

The requested object does not exist

class SourceStage.MultipleObjectsReturned(authentik.flows.models.Stage.MultipleObjectsReturned):

The query returned multiple objects when only one was expected.