Added functinality to declare custom login cookie expiration time.

Added login cookie expiration time. Added setting in user settings to declare custom cookie expiration time. Cookie expiration time overwrites default expiration time of 14 days (if not session timespan is used).
This commit is contained in:
Nico Pfaff
2023-11-09 16:15:53 +01:00
parent 12172168f6
commit 0b4cdea9dd
2 changed files with 15 additions and 0 deletions

View File

@ -31,6 +31,12 @@ namespace Oqtane.Extensions
builder.AddSiteNamedOptions<CookieAuthenticationOptions>(Constants.AuthenticationScheme, (options, alias, sitesettings) =>
{
options.Cookie.Name = sitesettings.GetValue("LoginOptions:CookieName", ".AspNetCore.Identity.Application");
string cookieExpStr = sitesettings.GetValue("LoginOptions:CookieExpiration", "");
if (!string.IsNullOrEmpty(cookieExpStr) && TimeSpan.TryParse(cookieExpStr, out TimeSpan cookieExpTS))
{
options.Cookie.Expiration = cookieExpTS;
options.ExpireTimeSpan = cookieExpTS;
}
});
// site OpenId Connect options