- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using Microsoft.Owin;
- using Microsoft.AspNet.Identity;
- using Microsoft.AspNet.Identity.Owin;
- using Microsoft.Owin.Security.Cookies;
- using Microsoft.Owin.Security.Google;
- using Owin;
- using eNtsaTrainingRegistration.Models;
- namespace eNtsaTrainingRegistration.App_Start
- {
- public partial class Startup
- {
- public void ConfigureAuth(IAppBuilder app)
- {
- // configure the db context, user manager and signin manager to a single instance per request.
- app.CreatePerOwinContext(ApplicationDbContext);
- app.CreatePerOwinContext
(ApplicationUserManager.Create); - app.CreatePerOwinContext
(ApplicationSignInManager.Create); - app.CreatePerOwinContext
(ApplicationRoleManager.Create); - // Configure sign cookie.
- app.UseCookieAuthentication(new CookieAuthenticationOptions
- {
- AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
- LoginPath = new PathString("/login"),
- Provider = new CookieAuthenticationProvider
- {
- // Enables the application to validate the security stamp when the user logs in.
- // This is a security feature which is used when you change a password or add an external login to your account.
- OnValidateIdentity = SecurityStampValidator.OnValidateIdentity
( - validateInterval: TimeSpan.FromMinutes(30),
- regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
- }
- });
- app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
- // Enables app to temperorily store user information when they are verified.
- app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
- // To remember when to login in.
- app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
- }
- }
- }
Loading
Rajanikant HawaldarPosted Feb 24, 2020, 2:55 AM