2fa helpers

This commit is contained in:
2022-12-13 16:25:36 +01:00
parent 8f3a20e5ba
commit c5cdb0f799
11 changed files with 297 additions and 26 deletions
+53
View File
@@ -0,0 +1,53 @@
using System.Security.Claims;
namespace zero.Identity;
public class TwoFactorKey
{
public string UserEmail { get; init; }
public string UnformattedKey { get; init; }
public string FormattedKey { get; init; }
public string AuthenticatorUrl { get; init; }
public string QrCodeSvg { get; set; }
public TwoFactorKeyOptions Options { get; init; }
}
public class TwoFactorKeyOptions
{
public string Issuer { get; set; }
public TwoFactorKeyLength Digits { get; set; } = TwoFactorKeyLength.Six;
public TwoFactorKeyAlgorithm Algorithm { get; set; } = TwoFactorKeyAlgorithm.SHA1;
public TwoFactorKeyRefreshPeriod Period { get; set; } = TwoFactorKeyRefreshPeriod.ThirtySeconds;
}
public enum TwoFactorKeyLength
{
Six = 6,
Seven = 7,
Eight = 8
}
public enum TwoFactorKeyAlgorithm
{
// ReSharper disable once InconsistentNaming
SHA1 = 0,
// ReSharper disable once InconsistentNaming
SHA256 = 1,
// ReSharper disable once InconsistentNaming
SHA512 = 2
}
public enum TwoFactorKeyRefreshPeriod
{
FifteenSeconds = 15,
ThirtySeconds = 30,
SixtySeconds = 60
}