ASP.Net身份2,双因素验证码时间跨度 [英] ASP.Net Identity 2, Two Factor Security Code timespan
本文介绍了ASP.Net身份2,双因素验证码时间跨度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们通过电子邮件使用2FA与ASP.Net身份2。这工作得很好大部分的时间,但在某些情况下,有通过向用户的电子邮件获得安全代码延迟,对安全代码的6分钟的窗口,然后变得太短。
We are using 2FA with ASP.Net Identity 2 via email. This works fine most of the time but in some cases there are delays with the security code getting through to users email, the 6-minute window for the security code then becomes too short.
是否有调整的2FA代码这个时间窗口的方法吗?
Is there a way of adjusting this time window for the 2FA code?
推荐答案
我觉得你必须改变的有效性。-timespan在 UserTokenProvider
I think you have to change the validity-timespan in the UserTokenProvider
.
试着在你的的UserManager<以下; TApplicationUser>
实施
public static ApplicationUserManager Create(
IdentityFactoryOptions<ApplicationUserManager> options,
IOwinContext context)
{
/* ...create the user store... */
var manager = new ApplicationUserManager(userStore);
/* ...all the other config stuff... */
var dataProtectionProvider = options.DataProtectionProvider;
if (dataProtectionProvider != null)
{
var tokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
// here's what you're looking for:
tokenProvider.TokenLifespan = TimeSpan.FromMinutes(10);
manager.UserTokenProvider = tokenProvider;
}
return manager;
}
这篇关于ASP.Net身份2,双因素验证码时间跨度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文