Class DefaultBackChannelLogoutService
- Namespace
- Fdyay.IdentityServer.Services
- Assembly
- Fdyay.IdentityServer.AspNetCore.dll
Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.
public class DefaultBackChannelLogoutService : IBackChannelLogoutService
- Inheritance
-
DefaultBackChannelLogoutService
- Implements
- Inherited Members
Remarks
Duende 8.0.1's DefaultBackChannelLogoutService, measured: the clients to be told become
BackChannelLogoutRequests, sent by protected steps — SendLogoutNotificationsAsync(IEnumerable<BackChannelLogoutRequest>, CancellationToken),
then for each CreateFormPostPayloadAsync(BackChannelLogoutRequest, CancellationToken) (with CreateTokenAsync(BackChannelLogoutRequest, CancellationToken) and
CreateClaimsForTokenAsync(BackChannelLogoutRequest)) and PostLogoutJwt(BackChannelLogoutRequest, Dictionary<string, string>, CancellationToken) — the virtual ones a host overrides to
deliver differently or to add to the token.
Where ours differs: SendLogoutNotificationsAsync(LogoutNotificationContext, CancellationToken), which
builds the requests, is not virtual, and puts the session id only on the request of a client that asked for it, so no
step is handed one to give away; each client is told concurrently and on its own, a failure raising
BackChannelLogoutFailureEvent rather than stopping the others; the token's lifetime is
BackChannelLogout.LogoutTokenLifetime, not Duende's fixed 300 seconds.
Constructors
DefaultBackChannelLogoutService(IClientStore, ITokenCreationService, IIssuerNameService, IBackChannelLogoutHttpClient, IOptions<IdentityServerOptions>, IEventService, TimeProvider, ILogger<DefaultBackChannelLogoutService>)
Creates the service, as the container resolves it.
public DefaultBackChannelLogoutService(IClientStore clients, ITokenCreationService tokens, IIssuerNameService issuerNameService, IBackChannelLogoutHttpClient httpClient, IOptions<IdentityServerOptions> options, IEventService events, TimeProvider time, ILogger<DefaultBackChannelLogoutService> logger)
Parameters
clientsIClientStoreFinds each client in the session, and its back-channel logout URI.
tokensITokenCreationServiceSigns each logout token.
issuerNameServiceIIssuerNameServiceNames this server as the logout tokens' issuer.
httpClientIBackChannelLogoutHttpClientPosts each logout token to its client.
optionsIOptions<IdentityServerOptions>The server options;
BackChannelLogout.LogoutTokenLifetimeis each token's lifetime.eventsIEventServiceReceives a BackChannelLogoutFailureEvent for each client that could not be told.
timeTimeProviderThe clock that stamps each logout token's creation time.
loggerILogger<DefaultBackChannelLogoutService>Receives the service's diagnostics.
Properties
HttpClient
What posts the token to a client. Duende's.
protected IBackChannelLogoutHttpClient HttpClient { get; }
Property Value
IssuerNameService
Where the issuer comes from when a request names none. Duende's.
protected IIssuerNameService IssuerNameService { get; }
Property Value
TimeProvider
The clock. Duende's.
protected TimeProvider TimeProvider { get; }
Property Value
Methods
CreateClaimsForTokenAsync(BackChannelLogoutRequest)
The logout token's claims: the event marker, sub, sid and logout_reason. Duende's.
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Duende's shape: an instance member a derived service calls.")]
protected Task<IEnumerable<Claim>> CreateClaimsForTokenAsync(BackChannelLogoutRequest request)
Parameters
requestBackChannelLogoutRequest
Returns
Exceptions
- ArgumentException
The client asked for the session id and there is none, or there is neither a subject nor a session to name.
CreateFormPostPayloadAsync(BackChannelLogoutRequest, CancellationToken)
The form to post: the logout token, as logout_token. Duende's.
protected Task<Dictionary<string, string>> CreateFormPostPayloadAsync(BackChannelLogoutRequest request, CancellationToken cancellationToken)
Parameters
requestBackChannelLogoutRequestcancellationTokenCancellationToken
Returns
CreateTokenAsync(BackChannelLogoutRequest, CancellationToken)
The logout token for one client, per OpenID Connect Back-Channel Logout 1.0 §2.4. Duende's step.
protected virtual Task<string> CreateTokenAsync(BackChannelLogoutRequest request, CancellationToken cancellationToken)
Parameters
requestBackChannelLogoutRequestcancellationTokenCancellationToken
Returns
PostLogoutJwt(BackChannelLogoutRequest, Dictionary<string, string>, CancellationToken)
Posts data to the client's back-channel logout URI. Duende's step.
protected virtual Task PostLogoutJwt(BackChannelLogoutRequest client, Dictionary<string, string> data, CancellationToken cancellationToken)
Parameters
clientBackChannelLogoutRequestdataDictionary<string, string>cancellationTokenCancellationToken
Returns
SendLogoutNotificationsAsync(LogoutNotificationContext, CancellationToken)
Notifies every client in the context that registered a back-channel logout URI.
public Task SendLogoutNotificationsAsync(LogoutNotificationContext context, CancellationToken cancellationToken = default)
Parameters
contextLogoutNotificationContextcancellationTokenCancellationToken
Returns
Remarks
Nothing is sent, and the omission is logged, when there is no request and no configured issuer. Only a client that asked for the session id (BackChannelLogoutSessionRequired) is sent it.
Exceptions
- ArgumentNullException
contextis null.
SendLogoutNotificationsAsync(IEnumerable<BackChannelLogoutRequest>, CancellationToken)
Tells each client in requests. Duende's step.
protected virtual Task SendLogoutNotificationsAsync(IEnumerable<BackChannelLogoutRequest> requests, CancellationToken cancellationToken)
Parameters
requestsIEnumerable<BackChannelLogoutRequest>cancellationTokenCancellationToken
Returns
Remarks
Concurrently and each on its own: a failure is logged and raised as BackChannelLogoutFailureEvent.