Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW: Cookie lifetime can be set in the appsettings.json #384

Merged
merged 2 commits into from Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -40,6 +40,9 @@ public class IdentityServerConfig
public WebClient WebClient { get; }
public MobileClient MobileClient { get; }
public ServerClient ServerClient { get; }

public bool CookieSlidingExpiration { get; }
public int CookieExpirationMinutes { get; }

public IdentityServerConfig(IConfiguration configuration)
{
Expand All @@ -49,7 +52,9 @@ public IdentityServerConfig(IConfiguration configuration)
UseGoogleLogin = identityServerSection.GetValue("UseGoogleLogin", false);
GoogleClientId = identityServerSection["GoogleClientId"] ?? "";
GoogleClientSecret = identityServerSection["GoogleClientSecret"] ?? "";

CookieSlidingExpiration = identityServerSection.GetValue("CookieSlidingExpiration", true);
CookieExpirationMinutes = identityServerSection.GetValue("CookieExpirationMinutes", 60);

var webClientSection = identityServerSection
.GetSection("WebClient");
if (webClientSection.GetChildren().Count() != 0)
Expand Down
8 changes: 7 additions & 1 deletion backend/Origam.Server/Startup.cs
Expand Up @@ -139,7 +139,13 @@ public void ConfigureServices(IServiceCollection services)
identityServerConfig.PathToJwtCertificate,
identityServerConfig.PasswordForJwtCertificate))
.AddInMemoryApiScopes(Settings.GetApiScopes());


services.ConfigureApplicationCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromMinutes(identityServerConfig.CookieExpirationMinutes);
options.SlidingExpiration = identityServerConfig.CookieSlidingExpiration;
});

services.AddSoapCore();
services.AddSingleton<DataServiceSoap>();
services.AddSingleton<WorkflowServiceSoap>();
Expand Down
2 changes: 2 additions & 0 deletions backend/Origam.Server/TemplateFiles/_appsettings.json
Expand Up @@ -27,6 +27,8 @@
"Html5ClientLogoUrl": "/customAssets/someFile2.png"
},
"IdentityServerConfig": {
"CookieExpirationMinutes": 60,
"CookieSlidingExpiration": true,
"PathToJwtCertificate": "serverCore.pfx",
"PasswordForJwtCertificate": "bla",
"UseGoogleLogin": "false",
Expand Down