Namespace Arc4u.Blazor
Classes
- AppPrincipalFromAuthenticationState
Rebuilds the AppPrincipal from the authentication state serialized by the Blazor server, and sets it in the IApplicationContext.
- AppPrincipalServerAuthenticationStateProvider
Server (Interactive Server / SignalR circuit) counterpart of the WebAssembly
Arc4u.Blazor.AppPrincipalFromAuthenticationStateused on the client: it sets the user's AppPrincipal in the circuit, and ends the circuit's sign-in when the user's sign-in has ended.
- ApplicationContextCircuitHandler
Populates the circuit-scoped IApplicationContext for Interactive Server components.
An Interactive Server component runs in a SignalR circuit that owns its own DI scope, distinct from the HTTP request scope where
AppPrincipalTransform(and, during prerendering, AppPrincipalServerAuthenticationStateProvider) populate the request-scoped IApplicationContext. That request scope is disposed once the response is sent, so the circuit starts with an empty IApplicationContext and component event handlers (e.g. a button click on the Counter page) see a nullPrincipal.This handler resolves the circuit-scoped AuthenticationStateProvider once the SignalR connection is up and builds the AppPrincipal into the circuit-scoped IApplicationContext, so it is available for the whole lifetime of the circuit — independent of whether/when the render pipeline re-invokes
GetAuthenticationStateAsync.It also follows the changes of the circuit's authentication state: when the circuit reconnects, Blazor sets the user of the new connection after the OnConnectionUpAsync(Circuit, CancellationToken) handlers ran, and a revalidating provider can turn the state anonymous. Nothing reads the state again after such a change, so the handler rebuilds the principal from the new state, or clears it for an anonymous user. Clearing also removes the user's principal and tokens from the request scope of the SignalR connection, which
IScopedServiceProviderAccessorresolves in the circuit and theJwtHttpHandlerand gRPC interceptor read.
- AuthenticationStateClaimsSerializer
Writes the signed-in user's authentication state into the page for the WebAssembly client with only the claims the client needs: the name claim, the role claims, and the claim types the application lists. It replaces
SerializeAllClaims = true, which sends every claim of the user to the browser.
- CircuitRevalidationExtensions
Registers the Arc4u authentication state of Blazor circuits, with the periodic check that their sign-in still exists.
- CircuitRevalidationOptions
Configures how an open Blazor circuit checks that the sign-in it started with still exists (see AppPrincipalServerAuthenticationStateProvider).
- SessionKeyTicketStore
Wraps the session store of the authentication cookie so the ticket it hands back carries its own session key as the SessionKey claim.
- SessionStoreSignInValidator
Checks the sign-in against the session store of the authentication cookie: the sign-in exists as long as the store still holds the ticket whose key the principal carries (the SessionKey claim, stamped by SessionKeyTicketStore, which
AddAppPrincipalCircuitRevalidationwraps around the cookie's session store).
Interfaces
- IAppPrincipalAuthenticationStateProvider
Builds an authentication state whose user is an AppPrincipal from serialized authentication data.
- ISignInValidator
Tells whether the sign-in behind a principal still exists. AppPrincipalServerAuthenticationStateProvider asks it periodically for the user of each open circuit. The default implementation is SessionStoreSignInValidator; register another one to check the sign-in elsewhere (for example at the identity provider).