authentik.core.apps
authentik core app config
1"""authentik core app config""" 2 3from django.utils.translation import gettext_lazy as _ 4 5from authentik.blueprints.apps import ManagedAppConfig 6from authentik.tasks.schedules.common import ScheduleSpec 7from authentik.tenants.flags import Flag 8 9 10class Setup(Flag[bool], key="setup"): 11 12 default = False 13 visibility = "system" 14 15 16class AppAccessWithoutBindings(Flag[bool], key="core_default_app_access"): 17 18 default = True 19 visibility = "none" 20 description = _( 21 "Configure if applications without any policy/group/user bindings " 22 "should be accessible to any user." 23 ) 24 25 26class AuthentikCoreConfig(ManagedAppConfig): 27 """authentik core app config""" 28 29 name = "authentik.core" 30 label = "authentik_core" 31 verbose_name = "authentik Core" 32 mountpoint = "" 33 default = True 34 35 def import_related(self): 36 super().import_related() 37 self.import_module("authentik.core.setup.signals") 38 39 @ManagedAppConfig.reconcile_tenant 40 def source_inbuilt(self): 41 """Reconcile inbuilt source""" 42 from authentik.core.models import Source 43 44 Source.objects.update_or_create( 45 defaults={ 46 "name": "authentik Built-in", 47 "slug": "authentik-built-in", 48 }, 49 managed=Source.MANAGED_INBUILT, 50 ) 51 52 @property 53 def tenant_schedule_specs(self) -> list[ScheduleSpec]: 54 from authentik.core.tasks import clean_expired_models, clean_temporary_users 55 56 return [ 57 ScheduleSpec( 58 actor=clean_expired_models, 59 crontab="2-59/5 * * * *", 60 ), 61 ScheduleSpec( 62 actor=clean_temporary_users, 63 crontab="9-59/5 * * * *", 64 ), 65 ]
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
Inherited Members
17class AppAccessWithoutBindings(Flag[bool], key="core_default_app_access"): 18 19 default = True 20 visibility = "none" 21 description = _( 22 "Configure if applications without any policy/group/user bindings " 23 "should be accessible to any user." 24 )
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
Inherited Members
27class AuthentikCoreConfig(ManagedAppConfig): 28 """authentik core app config""" 29 30 name = "authentik.core" 31 label = "authentik_core" 32 verbose_name = "authentik Core" 33 mountpoint = "" 34 default = True 35 36 def import_related(self): 37 super().import_related() 38 self.import_module("authentik.core.setup.signals") 39 40 @ManagedAppConfig.reconcile_tenant 41 def source_inbuilt(self): 42 """Reconcile inbuilt source""" 43 from authentik.core.models import Source 44 45 Source.objects.update_or_create( 46 defaults={ 47 "name": "authentik Built-in", 48 "slug": "authentik-built-in", 49 }, 50 managed=Source.MANAGED_INBUILT, 51 ) 52 53 @property 54 def tenant_schedule_specs(self) -> list[ScheduleSpec]: 55 from authentik.core.tasks import clean_expired_models, clean_temporary_users 56 57 return [ 58 ScheduleSpec( 59 actor=clean_expired_models, 60 crontab="2-59/5 * * * *", 61 ), 62 ScheduleSpec( 63 actor=clean_temporary_users, 64 crontab="9-59/5 * * * *", 65 ), 66 ]
authentik core app config
40 @ManagedAppConfig.reconcile_tenant 41 def source_inbuilt(self): 42 """Reconcile inbuilt source""" 43 from authentik.core.models import Source 44 45 Source.objects.update_or_create( 46 defaults={ 47 "name": "authentik Built-in", 48 "slug": "authentik-built-in", 49 }, 50 managed=Source.MANAGED_INBUILT, 51 )
Reconcile inbuilt source
53 @property 54 def tenant_schedule_specs(self) -> list[ScheduleSpec]: 55 from authentik.core.tasks import clean_expired_models, clean_temporary_users 56 57 return [ 58 ScheduleSpec( 59 actor=clean_expired_models, 60 crontab="2-59/5 * * * *", 61 ), 62 ScheduleSpec( 63 actor=clean_temporary_users, 64 crontab="9-59/5 * * * *", 65 ), 66 ]
Get a list of schedule specs that must exist in each tenant