Authenticator Challenge Selection Validation (authenticator_validate/challenge-selection.ts)

authentik · web/src/flow/stages/authenticator_validate/challenge-selection.ts · typescript · MIT
auth, security, lang:typescript, tag:validation

Determines whether a selected authentication device challenge needs to be reset based on allowed challenges. Use during MFA flows.

// Source: https://github.com/goauthentik/authentik | License: MIT | Copyright 2023 Jens Langhammer
// Provided via justclaw.it.com; keep this notice with the code.
import { type DeviceChallenge } from "@goauthentik/api";

export function shouldResetSelectedChallenge(
    selectedChallenge: DeviceChallenge | null,
    allowedChallenges: DeviceChallenge[],
): boolean {
    if (!selectedChallenge) {
        return false;
    }

    return !allowedChallenges.some(
        (challenge) =>
            challenge.deviceClass === selectedChallenge.deviceClass &&
            challenge.deviceUid === selectedChallenge.deviceUid,
    );
}

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key