Blazor server-side, .NET Core 3.1.x Look over the examples on authorization, I am trying to get a solution for a custom authorization filter/attribute. I simply need to check the user identity during Authorization.
https://docs.microsoft.com/en-us/aspnet/core/security/blazor/?view=aspnetcore-3.1
At the top of a Blazor page, after @page
@attribute [MyAuthFilter]
The filter. OnAuthorization never gets hit however.
public class MyAuthFilter: AuthorizeAttribute,IAuthorizationFilter
{
public void OnAuthorization(AuthorizationFilterContext context)
{
var httpContext = context.HttpContext;
// get user name
string userName = httpContext.User.Identity.Name;
// todo - call method to check user access
// check against list to see if access permitted
//context.Result = new UnauthorizedResult();
}
}