예제 #1
0
	public void ConfigureAuth(IAppBuilder app)
	{
	
		 //configure the DbContext , user manager and role manager to use a single instance per request
		app.CreatePerOwinContext(ApplicationDbContext.Create);
		app.CratePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
		app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.Create);
		app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
		
		//Enalbe the application to use coolie to store information for signed in user
		//and to use a cookie to temporarily store information about user logging in with a third party login provider
		//confiugure the sign in cookie
		
		app.UseCookieAuthentification(new CookieAuthentica tionOptions
		{
			AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
			LoginPath = new PathString("/Account/Login"),
			Provider = new CookieAuthenticationProvider
			  {
			    //Enables the application to validate the security stamps the user logs in
				OnValidateIdentity = SecurityStampValidator.OnvalidateIndetity<ApplicationUserManager, ApplicationUser>(  
				validateInterval:TimeSpan.FromMinutes(30);
				regenerateIdentiy:(manager, user ) =>user.GenerateuserIdentityAsync(manager))
				
				
			  });