authentik.flows.apps

authentik flows app config

 1"""authentik flows app config"""
 2
 3from django.utils.translation import gettext_lazy as _
 4from prometheus_client import Gauge, Histogram
 5
 6from authentik.admin.flags import Flag
 7from authentik.blueprints.apps import ManagedAppConfig
 8from authentik.lib.utils.reflection import all_subclasses
 9
10GAUGE_FLOWS_CACHED = Gauge(
11    "authentik_flows_cached",
12    "Cached flows",
13    multiprocess_mode="livemostrecent",
14)
15HIST_FLOW_EXECUTION_STAGE_TIME = Histogram(
16    "authentik_flows_execution_stage_time",
17    "Duration each stage took to execute.",
18    ["stage_type", "method"],
19)
20HIST_FLOWS_PLAN_TIME = Histogram(
21    "authentik_flows_plan_time",
22    "Duration to build a plan for a flow",
23    ["flow_slug"],
24)
25
26
27class ContinuousLogin(Flag[bool], key="flows_continuous_login"):
28
29    default = False
30    visibility = "public"
31    description = _("Upon successful authentication, re-start authentication in other open tabs.")
32
33
34class AuthentikFlowsConfig(ManagedAppConfig):
35    """authentik flows app config"""
36
37    name = "authentik.flows"
38    label = "authentik_flows"
39    mountpoint = "flows/"
40    verbose_name = "authentik Flows"
41    default = True
42
43    def import_related(self):
44        from authentik.flows.models import Stage
45
46        for stage in all_subclasses(Stage):
47            _ = stage().view
48        return super().import_related()
GAUGE_FLOWS_CACHED = prometheus_client.metrics.Gauge(authentik_flows_cached)
HIST_FLOW_EXECUTION_STAGE_TIME = prometheus_client.metrics.Histogram(authentik_flows_execution_stage_time)
HIST_FLOWS_PLAN_TIME = prometheus_client.metrics.Histogram(authentik_flows_plan_time)
class ContinuousLogin(authentik.admin.flags.Flag[bool]):
28class ContinuousLogin(Flag[bool], key="flows_continuous_login"):
29
30    default = False
31    visibility = "public"
32    description = _("Upon successful authentication, re-start authentication in other open tabs.")

Abstract base class for generic types.

On Python 3.12 and newer, generic classes implicitly inherit from Generic when they declare a parameter list after the class's name::

class Mapping[KT, VT]:
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

On older versions of Python, however, generic classes have to explicitly inherit from Generic.

After a class has been declared to be generic, it can then be used as follows::

def lookup_name[KT, VT](mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
default = False
visibility = 'public'
description = 'Upon successful authentication, re-start authentication in other open tabs.'
class AuthentikFlowsConfig(authentik.blueprints.apps.ManagedAppConfig):
35class AuthentikFlowsConfig(ManagedAppConfig):
36    """authentik flows app config"""
37
38    name = "authentik.flows"
39    label = "authentik_flows"
40    mountpoint = "flows/"
41    verbose_name = "authentik Flows"
42    default = True
43
44    def import_related(self):
45        from authentik.flows.models import Stage
46
47        for stage in all_subclasses(Stage):
48            _ = stage().view
49        return super().import_related()

authentik flows app config

name = 'authentik.flows'
label = 'authentik_flows'
mountpoint = 'flows/'
verbose_name = 'authentik Flows'
default = True