I am using MVC client with IdentityServer3.AccessTokenValidation and Identity Server 4 as my IDP app.
I have added cookie timeout at below places, however seems like session never expires and doesn't automatically logout the user -
In MVC client -
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
ExpireTimeSpan = new TimeSpan(0, 20, 0, 0)
});
If I set time less than 20 hours, authorization request runs for infinite loop
In IDP app,
services.AddIdentityServer(
opt => new IdentityServer4.Configuration.IdentityServerOptions
{
Authentication = new IdentityServer4.Configuration.AuthenticationOptions()
{
CookieLifetime = TimeSpan.FromSeconds(60)
}
}
In IDP app,
.AddCookie("Cookies", opt => {
opt.ExpireTimeSpan = TimeSpan.FromSeconds(60);
opt.Cookie = new CookieBuilder() { Expiration = new TimeSpan(0,0,0,60) };
opt.Events.OnSigningIn = (context) =>
{
context.CookieOptions.Expires = DateTimeOffset.UtcNow.AddSeconds(60);
return Task.CompletedTask;
};
})