How to set validateInterval cookie in ASP.NET Core?

I am trying to install validateIntervalfor an ASP.NET 5 RC1 application that usesASP.NET Identity 3

I am trying to implement code in this answer.

there are many code examples like this answer , but it seems to be invalid in ASP.NET 5 RC1

  app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            Provider = new CookieAuthenticationProvider
            {
                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
        validateInterval: TimeSpan.FromMinutes(15)
            },
            ExpireTimeSpan = TimeSpan.FromMinutes(30)
        });

If I try to use the above code example in ASP.NET 5 RC1, I cannot how

Provideris not a property CookieAuthenticationOptions and Visual Studio cannot find CookieAuthenticationProviderin any namespace through its light bulb options.

How to install validateIntervalin ASP.NET 5 RC1?

+4
source share
1

IdentityOptions:

services.AddIdentity<AppUser, AppRole>(options =>
{
    options.SecurityStampValidationInterval = TimeSpan.FromMinutes(15);
}

CookieAuthenticationEvents:

app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
    Events = new CookieAuthenticationEvents()
    {
        OnValidatePrincipal = context =>
        {
            Microsoft.AspNet.Identity.SecurityStampValidator.ValidatePrincipalAsync(context);
            return Task.FromResult(0);
        },
    },
    ExpireTimeSpan = TimeSpan.FromMinutes(30)
});
+4

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


All Articles