I have build an application targeted at mobile devices. I would like to be able to check the "remember me" option when logging in, and then be automatically authenticated from that point on, whenever I visit the site (app) or click on a link in an SMS that directs my browser to an authenticated controller action.
Unfortunately, it seems that I must have something incorrectly set somewhere, as I am required to login almost every time I visit the site, even though I have selected "remember me".
In my Startup.Auth.cs file, I have the following in ConfigureAuth:
app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.Create); app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/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<ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) }, CookieName = "MyAuthCookie", CookieHttpOnly = true, CookieSecure = CookieSecureOption.Always, ExpireTimeSpan = TimeSpan.FromDays(30), SlidingExpiration = true }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
Could it have something to do with the SecurityStampValidator?
Any and all help or suggestions are welcome. Thanks!