Ich verwende derzeit ASP.NET Core Identity. Ich kann die Einstellung nicht herausfinden, um die Sitzungslänge zu verlängern, aber ich werde immer ausgeloggt - ich nehme an, es gibt einen gleitenden Ablauf von ~ 20 Minuten, aber ich kann die Einstellung nicht finden. Hinweis: Ich verwende Google als externes OAuth.ASP.NET Core Identity Ablauf (Google OAuth)
services.AddIdentity<ApplicationUser, IdentityRole>(o =>
{
o.Password.RequireDigit = false;
o.Password.RequireLowercase = false;
o.Password.RequireUppercase = false;
o.Password.RequireNonAlphanumeric = false;
o.Password.RequiredLength = 6;
o.SecurityStampValidationInterval = TimeSpan.FromHours(8);
o.Cookies.ExternalCookie.ExpireTimeSpan = TimeSpan.FromHours(8);
o.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromHours(8);
})
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
app.UseIdentityServer();
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = $"http://localhost:55504/",
RequireHttpsMetadata = false,
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
"name",
"given_name",
"family_name",
"role"
}
});
var googleOptions = serviceProvider.GetRequiredService<GoogleOptions>();
app.UseGoogleAuthentication(new GoogleOptions
{
AuthenticationScheme = "Google",
SignInScheme = "Identity.External",
ClientId = googleOptions.ClientId,
ClientSecret = googleOptions.ClientSecret
});
Mögliche doppelte von [Cookie-Authentifizierung, die zu früh in ASP.NET Core abläuft] (https://stackoverflow.com/questions/45595615/c ookie-authentication-ablauf-zu-bald-in-asp-net-core) – SteelToe
Wo und wie hosten Sie Ihre Anwendung? IIS? Azure-App-Dienst? Dann müssen Sie den Datenschutz aktivieren, damit Ihr Verschlüsselungsschlüssel für die Cookies den Neustart der Anwendung übersteht. Siehe [meine Antwort hier] (https://stackoverflow.com/a/47559544/455493) – Tseng