Table of Contents

Interface IUserSession

Namespace
Fdyay.IdentityServer.Services
Assembly
Fdyay.IdentityServer.AspNetCore.dll

Tracks what the signed-in browser session is, and which clients it has authenticated.

public interface IUserSession

Remarks

Front-channel logout needs both: a session identifier to tell a client which of its sessions ended, and the list of clients to notify. Neither can be recovered after the fact, so both are recorded as the session is used rather than reconstructed at signout.

Methods

AddClientIdAsync(string, CancellationToken)

Records that a client has been authenticated in this session.

Task AddClientIdAsync(string clientId, CancellationToken cancellationToken = default)

Parameters

clientId string
cancellationToken CancellationToken

Returns

Task

AddSamlSessionAsync(SamlSpSessionData, CancellationToken)

Records that this session issued an assertion to a SAML service provider, and what it said.

Task AddSamlSessionAsync(SamlSpSessionData session, CancellationToken cancellationToken = default)

Parameters

session SamlSpSessionData
cancellationToken CancellationToken

Returns

Task

Remarks

Duende 8.0.1's. Replaces the provider's earlier record, if it has one: a session holds one SAML session per service provider.

Kept apart from the client list rather than folded into it, because the two are different namespaces of identifier. Back-channel logout resolves every entry of the client list with FindClientByIdAsync; an entity id resolves to nothing there and would be skipped in silence, which is the shape this tree keeps finding rather than one to add. Single logout reads this list and resolves each entry against the service provider registry instead.

Breaking in 0.129.0. It was AddSamlServiceProviderAsync(string entityId), and the list GetSamlServiceProviderListAsync; a logout can only name a provider's session if the NameID and session index are kept with it.

GetClientListAsync(CancellationToken)

The clients authenticated in this session so far.

Task<IReadOnlyCollection<string>> GetClientListAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<IReadOnlyCollection<string>>

GetSamlSessionListAsync(CancellationToken)

The SAML service providers this session reached, which a sign-out has to notify.

Task<IReadOnlyCollection<SamlSpSessionData>> GetSamlSessionListAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<IReadOnlyCollection<SamlSpSessionData>>

GetSessionIdAsync(CancellationToken)

The current session's identifier, creating one if the session does not have it yet.

Task<string?> GetSessionIdAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<string>

GetUserAsync(CancellationToken)

The user signed in to this session, or null when nobody is.

Task<ClaimsPrincipal?> GetUserAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<ClaimsPrincipal>

Remarks

Duende 8.0.1's: the principal of the session's own cookie scheme, authenticated, which is not always HttpContext.User — that is whatever the host's default scheme says. Asked by CIBA completion, as Duende's (since 0.160.0); the endpoints read the session as they did before 0.158.0.

A default interface method, so a host's session written before 0.158.0 keeps compiling; one that does not implement it throws NotSupportedException when asked, rather than answering that nobody is signed in. Duende's interface has no default.

RemoveSamlSessionAsync(string, CancellationToken)

Forgets this session's SAML session with one service provider, so a sign-out does not notify it.

Task RemoveSamlSessionAsync(string entityId, CancellationToken cancellationToken = default)

Parameters

entityId string
cancellationToken CancellationToken

Returns

Task

Remarks

Duende 8.0.1's, measured from DefaultUserSession: every record for the entity id, compared ordinally, and nothing for nobody signed in. Nothing in Duende's assembly or this server calls it; it is for a host that ends one provider's session itself.

A default interface method for the same reason as GetUserAsync(CancellationToken), throwing NotSupportedException for a session that does not implement it.