Class FreshSessionCookieManager
- Namespace
- Arc4u.OAuth2.TicketStore
- Assembly
- Arc4u.OAuth2.AspNetCore.Authentication.dll
An ICookieManager that hides the authentication cookie from the cookie handler on the OpenID Connect callback
(a POST to CallbackPath of the AuthenticationScheme scheme),
so the sign-in that follows always stores the ticket under a new session key.
public sealed class FreshSessionCookieManager : ICookieManager
- Inheritance
-
FreshSessionCookieManager
- Implements
- Inherited Members
Remarks
When a session store is used, CookieAuthenticationHandler does not create a new session on sign-in if the request already carries a cookie pointing to a session that still exists: it renews that session key with the new ticket. A cookie planted in the victim's browser (from a sibling subdomain, or from the same origin through XSS) would then receive the victim's session, and the attacker, who holds the same cookie, would be signed in as the victim (session fixation). Hiding the incoming cookie on the callback makes the handler call StoreAsync(AuthenticationTicket) instead.
Only reading the request cookie is affected, and only on the callback: writing and deleting the cookie, and every other request, are delegated unchanged to the inner manager. The OpenID Connect correlation and nonce cookies are not managed by this instance and are not affected. The previous session, if any, is not removed: it expires with its time to live.
Constructors
FreshSessionCookieManager(ICookieManager)
Initializes a new instance of the FreshSessionCookieManager class.
public FreshSessionCookieManager(ICookieManager inner)
Parameters
innerICookieManagerThe manager the cookies are read from and written to, usually a ChunkingCookieManager.
Exceptions
- ArgumentNullException
inneris null.
Properties
Inner
Gets the manager the cookies are read from and written to.
public ICookieManager Inner { get; }
Property Value
Methods
AppendResponseCookie(HttpContext, string, string?, CookieOptions)
Append the given cookie to the response.
public void AppendResponseCookie(HttpContext context, string key, string? value, CookieOptions options)
Parameters
contextHttpContextkeystringvaluestringoptionsCookieOptions
DeleteCookie(HttpContext, string, CookieOptions)
Append a delete cookie to the response.
public void DeleteCookie(HttpContext context, string key, CookieOptions options)
Parameters
contextHttpContextkeystringoptionsCookieOptions
GetRequestCookie(HttpContext, string)
Retrieve a cookie of the given name from the request.
public string? GetRequestCookie(HttpContext context, string key)
Parameters
contextHttpContextkeystring
Returns
Remarks
Returns null on the OpenID Connect callback, so the cookie handler starts a new session.