authentik.stages.user_write.models
write stage models
1"""write stage models""" 2 3from django.db import models 4from django.utils.translation import gettext_lazy as _ 5from django.views import View 6from rest_framework.serializers import BaseSerializer 7 8from authentik.core.models import Group, UserTypes 9from authentik.flows.models import Stage 10 11 12class UserCreationMode(models.TextChoices): 13 """Behavior of user_write stage when a user is not set in the flow context""" 14 15 NEVER_CREATE = "never_create" 16 CREATE_WHEN_REQUIRED = "create_when_required" 17 ALWAYS_CREATE = "always_create" 18 19 20class UserWriteStage(Stage): 21 """Write pending data into the pending user, or if no user exists, 22 create a new user with the data.""" 23 24 user_creation_mode = models.TextField( 25 choices=UserCreationMode.choices, 26 default=UserCreationMode.CREATE_WHEN_REQUIRED, 27 ) 28 29 create_users_as_inactive = models.BooleanField( 30 default=False, 31 help_text=_("When set, newly created users are inactive and cannot login."), 32 ) 33 34 create_users_group = models.ForeignKey( 35 Group, 36 null=True, 37 default=None, 38 on_delete=models.SET_DEFAULT, 39 help_text=_("Optionally add newly created users to this group."), 40 ) 41 42 user_type = models.TextField( 43 choices=UserTypes.choices, 44 default=UserTypes.EXTERNAL, 45 ) 46 user_path_template = models.TextField( 47 default="", 48 blank=True, 49 ) 50 51 @property 52 def serializer(self) -> type[BaseSerializer]: 53 from authentik.stages.user_write.api import UserWriteStageSerializer 54 55 return UserWriteStageSerializer 56 57 @property 58 def view(self) -> type[View]: 59 from authentik.stages.user_write.stage import UserWriteStageView 60 61 return UserWriteStageView 62 63 @property 64 def component(self) -> str: 65 return "ak-stage-user-write-form" 66 67 class Meta: 68 verbose_name = _("User Write Stage") 69 verbose_name_plural = _("User Write Stages")
13class UserCreationMode(models.TextChoices): 14 """Behavior of user_write stage when a user is not set in the flow context""" 15 16 NEVER_CREATE = "never_create" 17 CREATE_WHEN_REQUIRED = "create_when_required" 18 ALWAYS_CREATE = "always_create"
Behavior of user_write stage when a user is not set in the flow context
21class UserWriteStage(Stage): 22 """Write pending data into the pending user, or if no user exists, 23 create a new user with the data.""" 24 25 user_creation_mode = models.TextField( 26 choices=UserCreationMode.choices, 27 default=UserCreationMode.CREATE_WHEN_REQUIRED, 28 ) 29 30 create_users_as_inactive = models.BooleanField( 31 default=False, 32 help_text=_("When set, newly created users are inactive and cannot login."), 33 ) 34 35 create_users_group = models.ForeignKey( 36 Group, 37 null=True, 38 default=None, 39 on_delete=models.SET_DEFAULT, 40 help_text=_("Optionally add newly created users to this group."), 41 ) 42 43 user_type = models.TextField( 44 choices=UserTypes.choices, 45 default=UserTypes.EXTERNAL, 46 ) 47 user_path_template = models.TextField( 48 default="", 49 blank=True, 50 ) 51 52 @property 53 def serializer(self) -> type[BaseSerializer]: 54 from authentik.stages.user_write.api import UserWriteStageSerializer 55 56 return UserWriteStageSerializer 57 58 @property 59 def view(self) -> type[View]: 60 from authentik.stages.user_write.stage import UserWriteStageView 61 62 return UserWriteStageView 63 64 @property 65 def component(self) -> str: 66 return "ak-stage-user-write-form" 67 68 class Meta: 69 verbose_name = _("User Write Stage") 70 verbose_name_plural = _("User Write Stages")
Write pending data into the pending user, or if no user exists, create a new user with the data.
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.
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.
52 @property 53 def serializer(self) -> type[BaseSerializer]: 54 from authentik.stages.user_write.api import UserWriteStageSerializer 55 56 return UserWriteStageSerializer
Get serializer for this model
58 @property 59 def view(self) -> type[View]: 60 from authentik.stages.user_write.stage import UserWriteStageView 61 62 return UserWriteStageView
Return StageView class that implements logic for this stage
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
- endpointstage
- invitationstage
- passwordstage
- promptstage
- authenticatorstaticstage
- authenticatorduostage
- authenticatoremailstage
- authenticatorsmsstage
- authenticatorwebauthnstage
- authenticatorvalidatestage
- captchastage
- identificationstage
- authenticatortotpstage
- consentstage
- denystage
- dummystage
- redirectstage
- userdeletestage
- userloginstage
- userlogoutstage
- userwritestage
- authenticatorendpointgdtcstage
- mutualtlsstage
- sourcestage
The requested object does not exist
The query returned multiple objects when only one was expected.