Class DefaultUserSession
- Namespace
- Duende.IdentityServer.Services
- Assembly
- Duende.IdentityServer.dll
Cookie-based session implementation
public class DefaultUserSession : IUserSession
- Inheritance
-
DefaultUserSession
- Implements
- Inherited Members
Constructors
DefaultUserSession(IHttpContextAccessor, IAuthenticationHandlerProvider, IdentityServerOptions, IClock, IServerUrls, ILogger<IUserSession>)
Initializes a new instance of the DefaultUserSession class.
public DefaultUserSession(IHttpContextAccessor httpContextAccessor, IAuthenticationHandlerProvider handlers, IdentityServerOptions options, IClock clock, IServerUrls urls, ILogger<IUserSession> logger)
Parameters
httpContextAccessor
IHttpContextAccessorThe HTTP context accessor.
handlers
IAuthenticationHandlerProviderThe handlers.
options
IdentityServerOptionsThe options.
clock
IClockThe clock.
urls
IServerUrlslogger
ILogger<IUserSession>The logger.
- See Also
Fields
Clock
The clock
protected readonly IClock Clock
Field Value
- See Also
Handlers
The handlers
protected readonly IAuthenticationHandlerProvider Handlers
Field Value
- See Also
HttpContextAccessor
The HTTP context accessor
protected readonly IHttpContextAccessor HttpContextAccessor
Field Value
- See Also
Logger
The logger
protected readonly ILogger Logger
Field Value
- See Also
Options
The options
protected readonly IdentityServerOptions Options
Field Value
- See Also
Principal
The principal
protected ClaimsPrincipal Principal
Field Value
- See Also
Properties
The properties
protected AuthenticationProperties Properties
Field Value
- See Also
Urls
The server URL service.
protected readonly IServerUrls Urls
Field Value
- See Also
Properties
CheckSessionCookieDomain
Gets the domain of the check session cookie.
protected string CheckSessionCookieDomain { get; }
Property Value
- string
The domain of the check session cookie.
- See Also
CheckSessionCookieName
Gets the name of the check session cookie.
protected string CheckSessionCookieName { get; }
Property Value
- string
The name of the check session cookie.
- See Also
CheckSessionCookieSameSiteMode
Gets the SameSite mode of the check session cookie.
protected SameSiteMode CheckSessionCookieSameSiteMode { get; }
Property Value
- SameSiteMode
The SameSite mode of the check session cookie.
- See Also
HttpContext
Gets the HTTP context.
protected HttpContext HttpContext { get; }
Property Value
- HttpContext
The HTTP context.
- See Also
Methods
AddClientIdAsync(string)
Adds a client to the list of clients the user has signed into during their session.
public virtual Task AddClientIdAsync(string clientId)
Parameters
clientId
stringThe client identifier.
Returns
Exceptions
- ArgumentNullException
clientId
- See Also
AuthenticateAsync()
Authenticates the authentication cookie for the current HTTP request and caches the user and properties results.
protected virtual Task AuthenticateAsync()
Returns
- See Also
CreateSessionIdAsync(ClaimsPrincipal, AuthenticationProperties)
Creates a session identifier for the signin context and issues the session id cookie.
public virtual Task<string> CreateSessionIdAsync(ClaimsPrincipal principal, AuthenticationProperties properties)
Parameters
principal
ClaimsPrincipalproperties
AuthenticationProperties
Returns
Exceptions
- ArgumentNullException
principal or properties
- See Also
CreateSessionIdCookieOptions()
Creates the options for the session cookie.
public virtual CookieOptions CreateSessionIdCookieOptions()
Returns
- See Also
EnsureSessionIdCookieAsync()
Ensures the session identifier cookie is synchronized with the current session identifier. If there is no sid, the cookie is removed. If there is a sid, and the session identifier cookie is missing, it is issued.
public virtual Task EnsureSessionIdCookieAsync()
Returns
- See Also
GetClientListAsync()
Gets the list of clients the user has signed into during their session.
public virtual Task<IEnumerable<string>> GetClientListAsync()
Returns
- See Also
GetSessionIdAsync()
Gets the current session identifier.
public virtual Task<string> GetSessionIdAsync()
Returns
- See Also
GetUserAsync()
Gets the current authenticated user.
public virtual Task<ClaimsPrincipal> GetUserAsync()
Returns
- See Also
IssueSessionIdCookie(string)
Issues the cookie that contains the session id.
public virtual void IssueSessionIdCookie(string sid)
Parameters
sid
string
- See Also
RemoveSessionIdCookieAsync()
Removes the session identifier cookie.
public virtual Task RemoveSessionIdCookieAsync()
Returns
- See Also