ASP.Net 2 Identifier, Two-Factor Security Code

We use 2FA with ASP.Net 2 ID via email. This works great in most cases, but in some cases there are delays in receiving the security code for email users, the 6-minute window for the security code becomes too short.

Is there a way to configure this time window for 2FA code?

+6
source share
1 answer

I think you need to change the expiration date in UserTokenProvider .

Try the following steps in 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 what you're looking for: tokenProvider.TokenLifespan = TimeSpan.FromMinutes(10); manager.UserTokenProvider = tokenProvider; } return manager; } 
+1
source

Source: https://habr.com/ru/post/981392/


All Articles