What is the AuthenticationStateProvider, and how do you use it to access the current user's claims?
Last updated
AuthenticationStateProvideris the abstraction that supplies anAuthenticationStatewhoseUseris aClaimsPrincipal.Inject it and call
GetAuthenticationStateAsync(), or preferably receive a cascadingTask<AuthenticationState>parameter.Read
User.Identity.IsAuthenticatedandUser.Claims, or a specific claim withUser.FindFirst("type")?.Value.
- https://learn.microsoft.com/en-us/aspnet/core/blazor/security/authentication-state?view=aspnetcore-10.0
- https://www.youtube.com/watch?v=iq2btD9WufI
- https://learn.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-10.0
- https://code-maze.com/authenticationstateprovider-blazor-webassembly/
- https://blog.lhotka.net/2024/10/13/Accessing-User-Identity-on-a-Blazor-Wasm-Client