Path: redb-identity/src/redb.Identity.Contracts/Mfa/MfaManagementResponses.cs
Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity
Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Contracts/Mfa/MfaManagementResponses.cs
----
using System.Collections.Generic;
using System.Text.Json.Serialization;
using redb.Identity.Contracts.Common;
namespace redb.Identity.Contracts.Mfa;
/// The MFA state of a user, answered by the management MFA status operation.
public sealed class MfaStatusResponse
{
[JsonPropertyName("enabled")]
public required bool Enabled { get; init; }
/// Ids of the enrolled methods, e.g. totp.
[JsonPropertyName("methods")]
public required string[] Methods { get; init; }
[JsonPropertyName("recovery_codes_remaining")]
public required int RecoveryCodesRemaining { get; init; }
}
///
/// The answer of starting an MFA enrollment. It carries what the user needs to finish it, shown this once:
/// the TOTP secret and its otpauth:// URI, and the setup token the confirm call sends back. A method
/// may add its own members (the masked destination of an e-mail or SMS method).
///
public sealed class MfaSetupResponse
{
[JsonPropertyName("method")]
public required string Method { get; init; }
/// TOTP: the base32 shared secret; null for the other methods.
[OneTimeSecret]
[JsonPropertyName("secret_base32")]
public string? SecretBase32 { get; init; }
/// TOTP: the otpauth:// URI for a QR code; it contains the secret.
[OneTimeSecret]
[JsonPropertyName("qr_uri")]
public string? QrUri { get; init; }
/// Opaque encrypted token the confirm call must send back with the first code.
[OneTimeSecret]
[JsonPropertyName("setup_token")]
public string? SetupToken { get; init; }
/// Members a method adds, written after the others, e.g. masked_email.
[JsonExtensionData]
public Dictionary? Extra { get; init; }
}
/// The answer of confirming an MFA enrollment: the recovery codes, shown this once.
public sealed class MfaConfirmedResponse
{
/// Always true: a wrong code answers with instead.
[JsonPropertyName("confirmed")]
public bool Confirmed { get; } = true;
[OneTimeSecret]
[JsonPropertyName("recovery_codes")]
public required string[] RecoveryCodes { get; init; }
}
/// The answer of disabling an MFA method.
public sealed class MfaDisabledResponse
{
/// Always true.
[JsonPropertyName("disabled")]
public bool Disabled { get; } = true;
}
/// The answer of regenerating the recovery codes: the new codes, shown this once.
public sealed class MfaRecoveryCodesResponse
{
[OneTimeSecret]
[JsonPropertyName("recovery_codes")]
public required string[] RecoveryCodes { get; init; }
}