Table of Contents

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 IHttpContextAccessor

The HTTP context accessor.

handlers IAuthenticationHandlerProvider

The handlers.

options IdentityServerOptions

The options.

clock IClock

The clock.

urls IServerUrls
logger ILogger<IUserSession>

The logger.

See Also

Fields

Clock

The clock

protected readonly IClock Clock

Field Value

IClock
See Also

Handlers

The handlers

protected readonly IAuthenticationHandlerProvider Handlers

Field Value

IAuthenticationHandlerProvider
See Also

HttpContextAccessor

The HTTP context accessor

protected readonly IHttpContextAccessor HttpContextAccessor

Field Value

IHttpContextAccessor
See Also

Logger

The logger

protected readonly ILogger Logger

Field Value

ILogger
See Also

Options

The options

protected readonly IdentityServerOptions Options

Field Value

IdentityServerOptions
See Also

Principal

The principal

protected ClaimsPrincipal Principal

Field Value

ClaimsPrincipal
See Also

Properties

The properties

protected AuthenticationProperties Properties

Field Value

AuthenticationProperties
See Also

Urls

The server URL service.

protected readonly IServerUrls Urls

Field Value

IServerUrls
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 string

The client identifier.

Returns

Task

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

Task
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 ClaimsPrincipal
properties AuthenticationProperties

Returns

Task<string>

Exceptions

ArgumentNullException

principal or properties

See Also

CreateSessionIdCookieOptions()

Creates the options for the session cookie.

public virtual CookieOptions CreateSessionIdCookieOptions()

Returns

CookieOptions
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

Task
See Also

GetClientListAsync()

Gets the list of clients the user has signed into during their session.

public virtual Task<IEnumerable<string>> GetClientListAsync()

Returns

Task<IEnumerable<string>>
See Also

GetSessionIdAsync()

Gets the current session identifier.

public virtual Task<string> GetSessionIdAsync()

Returns

Task<string>
See Also

GetUserAsync()

Gets the current authenticated user.

public virtual Task<ClaimsPrincipal> GetUserAsync()

Returns

Task<ClaimsPrincipal>
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

Task
See Also

See Also