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

Commit

Permalink
Merge pull request #4711 from jhartmann123/cookie
Browse files Browse the repository at this point in the history
Allow setting SameSite mode of the SessionId cookie
  • Loading branch information
brockallen authored Oct 7, 2020
2 parents 7cf6192 + 4dc4090 commit 5c87628
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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

0 comments on commit 5c87628

Please sign in to comment.