stages/captcha: rework (#9959)

* stages/captcha: rework

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* update form with continue option

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* update docs, add notes for scores

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* also only raise error from success if needed

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* return full data

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L
2024-06-04 18:25:38 +09:00
committed by GitHub
parent 254761e930
commit 6cf418a37e
10 changed files with 295 additions and 18 deletions

View File

@ -1,5 +1,7 @@
import { BaseStageForm } from "@goauthentik/admin/stages/BaseStageForm";
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { first } from "@goauthentik/common/utils";
import "@goauthentik/components/ak-number-input";
import "@goauthentik/elements/forms/FormGroup";
import "@goauthentik/elements/forms/HorizontalFormElement";
@ -78,6 +80,40 @@ export class CaptchaStageForm extends BaseStageForm<CaptchaStage> {
)}
</p>
</ak-form-element-horizontal>
<ak-number-input
label=${msg("Score minimum threshold")}
required
name="scoreMinThreshold"
value="${ifDefined(this.instance?.scoreMinThreshold || 0.5)}"
help=${msg("Minimum required score to allow continuing")}
></ak-number-input>
<ak-number-input
label=${msg("Score maximum threshold")}
required
name="scoreMaxThreshold"
value="${ifDefined(this.instance?.scoreMaxThreshold || -1)}"
help=${msg("Maximum allowed score to allow continuing")}
></ak-number-input>
<ak-form-element-horizontal name="errorOnInvalidScore">
<label class="pf-c-switch">
<input
class="pf-c-switch__input"
type="checkbox"
?checked=${first(this.instance?.errorOnInvalidScore, true)}
/>
<span class="pf-c-switch__toggle">
<span class="pf-c-switch__toggle-icon">
<i class="fas fa-check" aria-hidden="true"></i>
</span>
</span>
<span class="pf-c-switch__label">${msg("Error on invalid score")}</span>
</label>
<p class="pf-c-form__helper-text">
${msg(
"When enabled and the resultant score is outside the threshold, the user will not be able to continue. When disabled, the user will be able to continue and the score can be used in policies to customize further stages.",
)}
</p>
</ak-form-element-horizontal>
</div>
</ak-form-group>
<ak-form-group>