stages/dummy: add toggle to throw error for debugging
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		| @ -12,7 +12,7 @@ class DummyStageSerializer(StageSerializer): | ||||
|     class Meta: | ||||
|  | ||||
|         model = DummyStage | ||||
|         fields = StageSerializer.Meta.fields | ||||
|         fields = StageSerializer.Meta.fields + ["throw_error"] | ||||
|  | ||||
|  | ||||
| class DummyStageViewSet(UsedByMixin, ModelViewSet): | ||||
|  | ||||
| @ -0,0 +1,18 @@ | ||||
| # Generated by Django 4.1.4 on 2023-01-01 19:31 | ||||
|  | ||||
| from django.db import migrations, models | ||||
|  | ||||
|  | ||||
| class Migration(migrations.Migration): | ||||
|  | ||||
|     dependencies = [ | ||||
|         ("authentik_stages_dummy", "0001_initial"), | ||||
|     ] | ||||
|  | ||||
|     operations = [ | ||||
|         migrations.AddField( | ||||
|             model_name="dummystage", | ||||
|             name="throw_error", | ||||
|             field=models.BooleanField(default=False), | ||||
|         ), | ||||
|     ] | ||||
| @ -1,5 +1,5 @@ | ||||
| """dummy stage models""" | ||||
|  | ||||
| from django.db import models | ||||
| from django.utils.translation import gettext as _ | ||||
| from django.views import View | ||||
| from rest_framework.serializers import BaseSerializer | ||||
| @ -10,6 +10,8 @@ from authentik.flows.models import Stage | ||||
| class DummyStage(Stage): | ||||
|     """Used for debugging.""" | ||||
|  | ||||
|     throw_error = models.BooleanField(default=False) | ||||
|  | ||||
|     __debug_only__ = True | ||||
|  | ||||
|     @property | ||||
|  | ||||
| @ -4,6 +4,7 @@ from rest_framework.fields import CharField | ||||
|  | ||||
| from authentik.flows.challenge import Challenge, ChallengeResponse, ChallengeTypes | ||||
| from authentik.flows.stage import ChallengeStageView | ||||
| from authentik.lib.sentry import SentryIgnoredException | ||||
|  | ||||
|  | ||||
| class DummyChallenge(Challenge): | ||||
| @ -27,6 +28,8 @@ class DummyStageView(ChallengeStageView): | ||||
|         return self.executor.stage_ok() | ||||
|  | ||||
|     def get_challenge(self, *args, **kwargs) -> Challenge: | ||||
|         if self.executor.current_stage.throw_error: | ||||
|             raise SentryIgnoredException("Test error") | ||||
|         return DummyChallenge( | ||||
|             data={ | ||||
|                 "type": ChallengeTypes.NATIVE.value, | ||||
|  | ||||
							
								
								
									
										10
									
								
								schema.yml
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								schema.yml
									
									
									
									
									
								
							| @ -21607,6 +21607,10 @@ paths: | ||||
|         schema: | ||||
|           type: string | ||||
|           format: uuid | ||||
|       - in: query | ||||
|         name: throw_error | ||||
|         schema: | ||||
|           type: boolean | ||||
|       tags: | ||||
|       - stages | ||||
|       security: | ||||
| @ -27177,6 +27181,8 @@ components: | ||||
|           type: array | ||||
|           items: | ||||
|             $ref: '#/components/schemas/FlowSet' | ||||
|         throw_error: | ||||
|           type: boolean | ||||
|       required: | ||||
|       - component | ||||
|       - meta_model_name | ||||
| @ -27195,6 +27201,8 @@ components: | ||||
|           type: array | ||||
|           items: | ||||
|             $ref: '#/components/schemas/FlowSetRequest' | ||||
|         throw_error: | ||||
|           type: boolean | ||||
|       required: | ||||
|       - name | ||||
|     DuoDevice: | ||||
| @ -33739,6 +33747,8 @@ components: | ||||
|           type: array | ||||
|           items: | ||||
|             $ref: '#/components/schemas/FlowSetRequest' | ||||
|         throw_error: | ||||
|           type: boolean | ||||
|     PatchedDuoDeviceRequest: | ||||
|       type: object | ||||
|       description: Serializer for Duo authenticator devices | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||||
| import { first } from "@goauthentik/common/utils"; | ||||
| import "@goauthentik/elements/forms/HorizontalFormElement"; | ||||
| import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; | ||||
|  | ||||
| @ -52,6 +53,16 @@ export class DummyStageForm extends ModelForm<DummyStage, string> { | ||||
|                     required | ||||
|                 /> | ||||
|             </ak-form-element-horizontal> | ||||
|             <ak-form-element-horizontal name="throwError"> | ||||
|                 <div class="pf-c-check"> | ||||
|                     <input | ||||
|                         type="checkbox" | ||||
|                         class="pf-c-check__input" | ||||
|                         ?checked=${first(this.instance?.throwError, false)} | ||||
|                     /> | ||||
|                     <label class="pf-c-check__label"> ${t`Throw error?`} </label> | ||||
|                 </div> | ||||
|             </ak-form-element-horizontal> | ||||
|         </form>`; | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer