Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Allow setting SameSite mode of the SessionId cookie #4711

Merged
merged 1 commit into from
Oct 7, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/reference/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Authentication
* ``CheckSessionCookieDomain``
The domain of the cookie used for the check session endpoint.

* ``CheckSessionCookieSameSiteMode``
The SameSite mode of the cookie used for the check session endpoint.

* ``RequireCspFrameSrcForSignout``
If set, will require frame-src CSP headers being emitting on the end session callback endpoint which renders iframes to clients for front-channel signout notification. Defaults to true.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public class AuthenticationOptions
/// </summary>
public string CheckSessionCookieDomain { get; set; }

/// <summary>
/// Gets or sets the SameSite mode of the cookie used for the check session endpoint. Defaults to SameSiteMode.None.
/// </summary>
public SameSiteMode CheckSessionCookieSameSiteMode { get; set; } = SameSiteMode.None;

/// <summary>
/// If set, will require frame-src CSP headers being emitting on the end session callback endpoint which renders iframes to clients for front-channel signout notification.
/// </summary>
Expand Down
10 changes: 9 additions & 1 deletion src/IdentityServer4/src/Services/Default/DefaultUserSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public class DefaultUserSession : IUserSession
/// </value>
protected string CheckSessionCookieDomain => Options.Authentication.CheckSessionCookieDomain;

/// <summary>
/// Gets the SameSite mode of the check session cookie.
/// </summary>
/// <value>
/// The SameSite mode of the check session cookie.
/// </value>
protected SameSiteMode CheckSessionCookieSameSiteMode => Options.Authentication.CheckSessionCookieSameSiteMode;

/// <summary>
/// The principal
/// </summary>
Expand Down Expand Up @@ -238,7 +246,7 @@ public virtual CookieOptions CreateSessionIdCookieOptions()
Path = path,
IsEssential = true,
Domain = CheckSessionCookieDomain,
SameSite = SameSiteMode.None
SameSite = CheckSessionCookieSameSiteMode
};

return options;
Expand Down