我在 ASP.NET 應用程式中使用GoogleAuthenticatornuget 包進行2FA身份驗證。問題是即使身份驗證器應用程式已經更改了代碼,該函式也ValidateTwoFactorPIN始終回傳。
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);
}
uj5u.com熱心網友回復:
該軟體包的默認漂移容差為5 分鐘,因此要么使用較小的容差進行測驗,要么等到容差視窗過去。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/383888.html
