【发布时间】:2022-01-19 02:54:59
【问题描述】:
我在 ASP.NET 应用程序中使用GoogleAuthenticator nuget 包进行2FA 身份验证。问题是函数ValidateTwoFactorPIN 总是返回true,即使验证器应用程序已经更改了TOTP 代码。 Nuget Package
public TwoFactorSetupResponse Enable(string email)
{
var accountSecretKey = $"{SecretCode}-{email}";
var setupInfo = _twoFactorAuthenticator.GenerateSetupCode("App", email, Encoding.ASCII.GetBytes(accountSecretKey));
return new TwoFactorSetupResponse()
{
Account = setupInfo.Account,
ManualEntryKey = setupInfo.ManualEntryKey,
QrCodeSetupImageUrl = setupInfo.QrCodeSetupImageUrl,
};
}
public bool IsCodeValid(string email, string code)
{
var accountSecretKey = $"{SecretCode}-{email}";
return _twoFactorAuthenticator.ValidateTwoFactorPIN(accountSecretKey, code);
}
【问题讨论】:
标签: asp.net .net .net-core google-2fa