Table of Contents

Class CircuitRevalidationExtensions

Namespace
Arc4u.Blazor
Assembly
Arc4u.OAuth2.AspNetCore.Blazor.dll

Registers the Arc4u authentication state of Blazor circuits, with the periodic check that their sign-in still exists.

public static class CircuitRevalidationExtensions
Inheritance
CircuitRevalidationExtensions
Inherited Members

Methods

AddAppPrincipalCircuitRevalidation(IServiceCollection, IConfiguration, string)

Same as AddAppPrincipalCircuitRevalidation(IServiceCollection, Action<CircuitRevalidationOptions>?), with the options read from a configuration section. The defaults are used when the section does not exist.

public static IServiceCollection AddAppPrincipalCircuitRevalidation(this IServiceCollection services, IConfiguration configuration, string sectionName = "Authentication:CircuitRevalidation")

Parameters

services IServiceCollection

The service collection.

configuration IConfiguration

The configuration.

sectionName string

The section holding the options. The default is DefaultSectionName.

Returns

IServiceCollection

The service collection.

Exceptions

ArgumentNullException

services or configuration is null.

AddAppPrincipalCircuitRevalidation(IServiceCollection, Action<CircuitRevalidationOptions>?)

Turns on the revalidation of Blazor circuits: wraps the session store of the cookie in a SessionKeyTicketStore so each principal carries its session key, makes AppPrincipalServerAuthenticationStateProvider the AuthenticationStateProvider (replacing any other registration), registers SessionStoreSignInValidator as the ISignInValidator unless another one is registered, adds the ApplicationContextCircuitHandler, and validates the CircuitRevalidationOptions at startup.

public static IServiceCollection AddAppPrincipalCircuitRevalidation(this IServiceCollection services, Action<CircuitRevalidationOptions>? configure = null)

Parameters

services IServiceCollection

The service collection.

configure Action<CircuitRevalidationOptions>

Configures the options; the defaults are used when it is null.

Returns

IServiceCollection

The service collection.

Examples

builder.Services.AddOidcAuthentication(builder.Configuration);
builder.Services.AddAppPrincipalCircuitRevalidation(o => o.Interval = TimeSpan.FromMinutes(1));

Remarks

Without this call the principals carry no session key and the default validator cannot check anything: the circuits keep their user until they reconnect. It can be called before or after AddOidcAuthentication; call it after any other registration of AuthenticationStateProvider, which it removes.

Exceptions

ArgumentNullException

services is null.

OptionsValidationException

At startup: Interval is not more than zero and at most MaxInterval, or the cookie scheme is empty.