Class CircuitRevalidationExtensions
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
servicesIServiceCollectionThe service collection.
configurationIConfigurationThe configuration.
sectionNamestringThe section holding the options. The default is DefaultSectionName.
Returns
- IServiceCollection
The service collection.
Exceptions
- ArgumentNullException
servicesorconfigurationis 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
servicesIServiceCollectionThe service collection.
configureAction<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
servicesis null.- OptionsValidationException
At startup: Interval is not more than zero and at most MaxInterval, or the cookie scheme is empty.