I am trying to secure my blazor client-side app and have followed instructions from here https://docs.microsoft.com/en-us/aspnet/core/security/blazor/?view=aspnetcore-3.0&tabs=visual-studio
What confuses me is this section
public override Task<AuthenticationState> GetAuthenticationStateAsync()
{
var identity = new ClaimsIdentity(new[]
{
new Claim(ClaimTypes.Name, "mrfibuli"),
}, "Fake authentication type");
var user = new ClaimsPrincipal(identity);
return Task.FromResult(new AuthenticationState(user));
}
Since authorization is only used to determine which UI options to show and client-side checks can be modified or bypassed by a user a Blazor WebAssembly app can't enforce authorization access rules.
So if I got it right, this is the valid procedure
- user sends credentials via page/form
- api returns a token
- token is stored locally
- reverse mechanism is implemented in GetAuthenticationStateAsync where a token is exchanged for user info