Skip to content

Commit

Permalink
Merge pull request #11 from Intrepiware/extend-login-timeout
Browse files Browse the repository at this point in the history
Extend login timeout to 1 year
  • Loading branch information
Intrepiware authored Jan 7, 2024
2 parents 6e131b0 + 7607648 commit a0a626b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion WorkoutBuilder.Services/Impl/AuthenticationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public async Task<bool> Login(string username, string password)
var claims = GetClaims(user);
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var principal = new ClaimsPrincipal(identity);
await HttpContextAccessor.HttpContext.SignInAsync(principal);
await HttpContextAccessor.HttpContext.SignInAsync(principal,
new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTime.UtcNow.AddDays(365) });
return true;
}

Expand Down
7 changes: 6 additions & 1 deletion WorkoutBuilder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BotDetect.Web;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using WorkoutBuilder.Data;
using WorkoutBuilder.IOC;
using WorkoutBuilder.Middleware;
Expand Down Expand Up @@ -37,7 +38,11 @@ public static void Main(string[] args)
.AddCookie("CookieAuth", config =>
{
config.Cookie.Name = "WorkoutBuild";
config.LoginPath = "/Users/Login";
config.LoginPath = "/Users/Login";
config.Cookie.HttpOnly = true;
config.Cookie.IsEssential = true;
config.Cookie.SameSite = SameSiteMode.Strict;
config.Cookie.SecurePolicy = CookieSecurePolicy.Always;
});

// This setting allows the CAPTCHA to generate images
Expand Down

0 comments on commit a0a626b

Please sign in to comment.