Table of Contents

Class OidcAuthenticationStateProvider

Namespace
NuvTools.Security.AspNetCore.Blazor
Assembly
NuvTools.Security.AspNetCore.Blazor.dll

Provides an AuthenticationStateProvider implementation for Blazor WebAssembly applications that use OpenID Connect (OIDC) authentication.

public class OidcAuthenticationStateProvider : AuthenticationStateProvider
Inheritance
OidcAuthenticationStateProvider
Inherited Members

Remarks

This provider retrieves and parses access tokens using an IAccessTokenProvider, enabling JWT-based user claims to be extracted and tracked for authorization.

Constructors

OidcAuthenticationStateProvider(IAccessTokenProvider)

Provides an AuthenticationStateProvider implementation for Blazor WebAssembly applications that use OpenID Connect (OIDC) authentication.

public OidcAuthenticationStateProvider(IAccessTokenProvider tokenProvider)

Parameters

tokenProvider IAccessTokenProvider

Remarks

This provider retrieves and parses access tokens using an IAccessTokenProvider, enabling JWT-based user claims to be extracted and tracked for authorization.

Properties

CurrentUser

Gets the current authenticated user represented by a ClaimsPrincipal.

public ClaimsPrincipal? CurrentUser { get; }

Property Value

ClaimsPrincipal

Methods

GetAuthenticationStateAsync()

Asynchronously retrieves the current authentication state.

public override Task<AuthenticationState> GetAuthenticationStateAsync()

Returns

Task<AuthenticationState>

An AuthenticationState representing either the authenticated user or an anonymous identity if the token could not be obtained or is invalid.

Remarks

This method is called by the Blazor authorization infrastructure to determine the current user’s identity. If a valid access token is present, it will parse the claims from the JWT; otherwise, it returns an anonymous user.