Man*_*rok 6 c# asp.net asp.net-identity-2
我们通过电子邮件使用2FA和ASP.Net Identity 2.这在大多数情况下工作正常,但在某些情况下,安全代码会延迟到用户电子邮件,安全代码的6分钟窗口会变得太短.
有没有办法调整2FA代码的这个时间窗口?
我认为你必须更改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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
642 次 |
| 最近记录: |