I have identityserver4 with aspnetidentity, it is working but on server restarts the application redirects user to signing again.
services.AddIdentityServer(options =>
{
options.Events.RaiseSuccessEvents = true;
options.Events.RaiseFailureEvents = true;
options.Events.RaiseErrorEvents = true;
//options.Authentication.CookieLifetime = TimeSpan.FromSeconds(30);
options.Authentication.CookieLifetime = TimeSpan.FromMinutes(20);
}).AddSigningCredential(cert)
//.AddInMemoryIdentityResources(Config.GetIdentityResources())
//.AddInMemoryApiResources(Config.GetApiResources())
//.AddInMemoryClients(Config.GetClients())
//.AddTestUsers(Config.GetUsers());
.AddConfigurationStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddOperationalStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddAspNetIdentity<ApplicationUser>()
.AddProfileService<ProfileService>();
with access token I don't have any issue, because it is with the client browser in cookie format. no matter if server restarts still the resource allow.
but id_token which is the same case, however when the request goes to Idmsrv endpoints connect/authorize it gets the user to login again.
Persists the keys to disk rather in memory so it will have a key when the cookie come back to server to decrypt using the key.
//REFERENCE https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/key-storage-providers
//REFERENCE persists keys http://www.tugberkugurlu.com/archive/asp-net-core-authentication-in-a-load-balanced-environment-with-haproxy-and-redis
services.AddDataProtection() //Microsoft.AspNetCore.DataProtection.Redis package
.PersistKeysToFileSystem(new DirectoryInfo("F:\\Jana\\Certs\\Keys\\"));