authentik.stages.captcha.models
authentik captcha stage
1"""authentik captcha stage""" 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.flows.models import Stage 9 10 11class CaptchaRequestContentType(models.TextChoices): 12 """Supported request content types for CAPTCHA verification.""" 13 14 FORM = "application/x-www-form-urlencoded", _("Form encoded") 15 JSON = "application/json", _("JSON") 16 17 18class CaptchaStage(Stage): 19 """Verify the user is human using Google's reCaptcha/other compatible CAPTCHA solutions.""" 20 21 public_key = models.TextField(help_text=_("Public key, acquired your captcha Provider.")) 22 private_key = models.TextField(help_text=_("Private key, acquired your captcha Provider.")) 23 24 interactive = models.BooleanField(default=False) 25 26 score_min_threshold = models.FloatField(default=0.5) # Default values for reCaptcha 27 score_max_threshold = models.FloatField(default=1.0) # Default values for reCaptcha 28 29 error_on_invalid_score = models.BooleanField( 30 default=True, 31 help_text=_( 32 "When enabled and the received captcha score is outside of the given threshold, " 33 "the stage will show an error message. When not enabled, the flow will continue, " 34 "but the data from the captcha will be available in the context for policy decisions" 35 ), 36 ) 37 38 js_url = models.TextField(default="https://www.recaptcha.net/recaptcha/api.js") 39 api_url = models.TextField(default="https://www.recaptcha.net/recaptcha/api/siteverify") 40 request_content_type = models.TextField( 41 choices=CaptchaRequestContentType.choices, 42 default=CaptchaRequestContentType.FORM, 43 ) 44 45 @property 46 def serializer(self) -> type[BaseSerializer]: 47 from authentik.stages.captcha.api import CaptchaStageSerializer 48 49 return CaptchaStageSerializer 50 51 @property 52 def view(self) -> type[View]: 53 from authentik.stages.captcha.stage import CaptchaStageView 54 55 return CaptchaStageView 56 57 @property 58 def component(self) -> str: 59 return "ak-stage-captcha-form" 60 61 class Meta: 62 verbose_name = _("Captcha Stage") 63 verbose_name_plural = _("Captcha Stages")
12class CaptchaRequestContentType(models.TextChoices): 13 """Supported request content types for CAPTCHA verification.""" 14 15 FORM = "application/x-www-form-urlencoded", _("Form encoded") 16 JSON = "application/json", _("JSON")
Supported request content types for CAPTCHA verification.
19class CaptchaStage(Stage): 20 """Verify the user is human using Google's reCaptcha/other compatible CAPTCHA solutions.""" 21 22 public_key = models.TextField(help_text=_("Public key, acquired your captcha Provider.")) 23 private_key = models.TextField(help_text=_("Private key, acquired your captcha Provider.")) 24 25 interactive = models.BooleanField(default=False) 26 27 score_min_threshold = models.FloatField(default=0.5) # Default values for reCaptcha 28 score_max_threshold = models.FloatField(default=1.0) # Default values for reCaptcha 29 30 error_on_invalid_score = models.BooleanField( 31 default=True, 32 help_text=_( 33 "When enabled and the received captcha score is outside of the given threshold, " 34 "the stage will show an error message. When not enabled, the flow will continue, " 35 "but the data from the captcha will be available in the context for policy decisions" 36 ), 37 ) 38 39 js_url = models.TextField(default="https://www.recaptcha.net/recaptcha/api.js") 40 api_url = models.TextField(default="https://www.recaptcha.net/recaptcha/api/siteverify") 41 request_content_type = models.TextField( 42 choices=CaptchaRequestContentType.choices, 43 default=CaptchaRequestContentType.FORM, 44 ) 45 46 @property 47 def serializer(self) -> type[BaseSerializer]: 48 from authentik.stages.captcha.api import CaptchaStageSerializer 49 50 return CaptchaStageSerializer 51 52 @property 53 def view(self) -> type[View]: 54 from authentik.stages.captcha.stage import CaptchaStageView 55 56 return CaptchaStageView 57 58 @property 59 def component(self) -> str: 60 return "ak-stage-captcha-form" 61 62 class Meta: 63 verbose_name = _("Captcha Stage") 64 verbose_name_plural = _("Captcha Stages")
Verify the user is human using Google's reCaptcha/other compatible CAPTCHA solutions.
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.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
46 @property 47 def serializer(self) -> type[BaseSerializer]: 48 from authentik.stages.captcha.api import CaptchaStageSerializer 49 50 return CaptchaStageSerializer
Get serializer for this model
52 @property 53 def view(self) -> type[View]: 54 from authentik.stages.captcha.stage import CaptchaStageView 55 56 return CaptchaStageView
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.
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.flows.models.Stage
- stage_uuid
- name
- objects
- ui_user_settings
- is_in_memory
- flow_set
- flowstagebinding_set
- emailstage
- passwordstage
- endpointstage
- invitationstage
- promptstage
- authenticatorstaticstage
- authenticatorduostage
- authenticatoremailstage
- authenticatorsmsstage
- authenticatorwebauthnstage
- authenticatorvalidatestage
- authenticator_validate_stage_m2m_objects
- captchastage
- identificationstage
- authenticatortotpstage
- consentstage
- denystage
- dummystage
- redirectstage
- userdeletestage
- userloginstage
- userlogoutstage
- userwritestage
- accountlockdownstage
- authenticatorendpointgdtcstage
- mutualtlsstage
- sourcestage
The requested object does not exist
The query returned multiple objects when only one was expected.