stages/dummy: add toggle to throw error for debugging
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
b9bb27008e
commit
9fdfb8c99b
|
@ -12,7 +12,7 @@ class DummyStageSerializer(StageSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
model = DummyStage
|
model = DummyStage
|
||||||
fields = StageSerializer.Meta.fields
|
fields = StageSerializer.Meta.fields + ["throw_error"]
|
||||||
|
|
||||||
|
|
||||||
class DummyStageViewSet(UsedByMixin, ModelViewSet):
|
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"""
|
"""dummy stage models"""
|
||||||
|
from django.db import models
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from rest_framework.serializers import BaseSerializer
|
from rest_framework.serializers import BaseSerializer
|
||||||
|
@ -10,6 +10,8 @@ from authentik.flows.models import Stage
|
||||||
class DummyStage(Stage):
|
class DummyStage(Stage):
|
||||||
"""Used for debugging."""
|
"""Used for debugging."""
|
||||||
|
|
||||||
|
throw_error = models.BooleanField(default=False)
|
||||||
|
|
||||||
__debug_only__ = True
|
__debug_only__ = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -4,6 +4,7 @@ from rest_framework.fields import CharField
|
||||||
|
|
||||||
from authentik.flows.challenge import Challenge, ChallengeResponse, ChallengeTypes
|
from authentik.flows.challenge import Challenge, ChallengeResponse, ChallengeTypes
|
||||||
from authentik.flows.stage import ChallengeStageView
|
from authentik.flows.stage import ChallengeStageView
|
||||||
|
from authentik.lib.sentry import SentryIgnoredException
|
||||||
|
|
||||||
|
|
||||||
class DummyChallenge(Challenge):
|
class DummyChallenge(Challenge):
|
||||||
|
@ -27,6 +28,8 @@ class DummyStageView(ChallengeStageView):
|
||||||
return self.executor.stage_ok()
|
return self.executor.stage_ok()
|
||||||
|
|
||||||
def get_challenge(self, *args, **kwargs) -> Challenge:
|
def get_challenge(self, *args, **kwargs) -> Challenge:
|
||||||
|
if self.executor.current_stage.throw_error:
|
||||||
|
raise SentryIgnoredException("Test error")
|
||||||
return DummyChallenge(
|
return DummyChallenge(
|
||||||
data={
|
data={
|
||||||
"type": ChallengeTypes.NATIVE.value,
|
"type": ChallengeTypes.NATIVE.value,
|
||||||
|
|
10
schema.yml
10
schema.yml
|
@ -21607,6 +21607,10 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
|
- in: query
|
||||||
|
name: throw_error
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
tags:
|
tags:
|
||||||
- stages
|
- stages
|
||||||
security:
|
security:
|
||||||
|
@ -27177,6 +27181,8 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/FlowSet'
|
$ref: '#/components/schemas/FlowSet'
|
||||||
|
throw_error:
|
||||||
|
type: boolean
|
||||||
required:
|
required:
|
||||||
- component
|
- component
|
||||||
- meta_model_name
|
- meta_model_name
|
||||||
|
@ -27195,6 +27201,8 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/FlowSetRequest'
|
$ref: '#/components/schemas/FlowSetRequest'
|
||||||
|
throw_error:
|
||||||
|
type: boolean
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
DuoDevice:
|
DuoDevice:
|
||||||
|
@ -33739,6 +33747,8 @@ components:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/FlowSetRequest'
|
$ref: '#/components/schemas/FlowSetRequest'
|
||||||
|
throw_error:
|
||||||
|
type: boolean
|
||||||
PatchedDuoDeviceRequest:
|
PatchedDuoDeviceRequest:
|
||||||
type: object
|
type: object
|
||||||
description: Serializer for Duo authenticator devices
|
description: Serializer for Duo authenticator devices
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||||
|
import { first } from "@goauthentik/common/utils";
|
||||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||||
|
|
||||||
|
@ -52,6 +53,16 @@ export class DummyStageForm extends ModelForm<DummyStage, string> {
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</ak-form-element-horizontal>
|
</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>`;
|
</form>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue