diff --git a/src/Fancy.ResourceLinker.Gateway/Authentication/GatewayAuthentication.cs b/src/Fancy.ResourceLinker.Gateway/Authentication/GatewayAuthentication.cs
index a164d09..bf67c3d 100644
--- a/src/Fancy.ResourceLinker.Gateway/Authentication/GatewayAuthentication.cs
+++ b/src/Fancy.ResourceLinker.Gateway/Authentication/GatewayAuthentication.cs
@@ -54,10 +54,14 @@ internal static void AddGatewayAuthentication(IServiceCollection services, Gatew
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
+ // Add cookie settings
.AddCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromMinutes(settings.SessionTimeoutInMin);
options.SlidingExpiration = true;
+ options.Cookie.SameSite = settings.CookieSettings.SameSiteStrict == true ? SameSiteMode.Strict : SameSiteMode.Lax;
+ options.Cookie.SecurePolicy = settings.CookieSettings.Secure == true ? CookieSecurePolicy.Always : CookieSecurePolicy.SameAsRequest;
+ options.Cookie.HttpOnly = settings.CookieSettings.HttpOnly;
})
.AddOpenIdConnect(options =>
{
diff --git a/src/Fancy.ResourceLinker.Gateway/Authentication/GatewayAuthenticationSettings.cs b/src/Fancy.ResourceLinker.Gateway/Authentication/GatewayAuthenticationSettings.cs
index 9db2e06..0bbff4e 100644
--- a/src/Fancy.ResourceLinker.Gateway/Authentication/GatewayAuthenticationSettings.cs
+++ b/src/Fancy.ResourceLinker.Gateway/Authentication/GatewayAuthenticationSettings.cs
@@ -78,6 +78,15 @@ public class GatewayAuthenticationSettings
///
public string? IssuerAddressForSignOut { get; set; }
+ ///
+ /// Gets or sets the cookiesettings.
+ ///
+ ///
+ /// Set cookiesettings.
+ ///
+ public CookieSettings CookieSettings { get; set; } = new CookieSettings();
+
+
public void Validate()
{
// Check required fields
@@ -97,3 +106,33 @@ public void Validate()
}
}
}
+
+public class CookieSettings
+{
+ ///
+ /// Gets or sets the SameSite policy
+ ///
+ ///
+ /// true || Not set == Strict
+ /// false == Lax
+ ///
+ public bool SameSiteStrict { get; set; } = true;
+ ///
+ ///
+ /// Gets or sets the secure flag.
+ ///
+ ///
+ /// true || Not set == Always
+ /// false == SameAsRequest
+ ///
+ public bool Secure { get; set; } = true;
+ ///
+ ///
+ /// Gets or sets the HttpOnly setting.
+ ///
+ ///
+ /// true || Not set == true
+ /// false == false
+ ///
+ public bool HttpOnly { get; set; } = true;
+}