Skip to content

Commit

Permalink
This hotfix allows us to turn on and off secure cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
carlsixsmith-moj committed Aug 15, 2024
1 parent c7a0f9f commit c3c5bc7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,17 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti

services.AddSingleton<IPasswordService, PasswordService>();

CookieSecurePolicy policy = CookieSecurePolicy.SameAsRequest;
if(configuration["IdentitySettings:SecureCookies"] is not null && configuration["IdentitySettings:SecureCookies"]!.Equals("True", StringComparison.CurrentCultureIgnoreCase))
{
policy = CookieSecurePolicy.Always;
}


services.ConfigureApplicationCookie(options => {
options.LoginPath = "/pages/authentication/login";
options.Cookie.SameSite = SameSiteMode.Strict;
options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
options.Cookie.SecurePolicy = policy;
});

services
Expand Down
3 changes: 2 additions & 1 deletion src/Server.UI/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"RequireUpperCase": true,
"RequireLowerCase": true,
"DefaultLockoutTimeSpan": 30,
"MaxFailedAccessAttempts": 5
"MaxFailedAccessAttempts": 5,
"SecureCookies": true
},
"Notify": {
"ApiKey": "",
Expand Down

0 comments on commit c3c5bc7

Please sign in to comment.