I’ve created an IDashboardAuthorizationFilter
as follows.
public class HangfireAuthorizationFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
var httpContext = context.GetHttpContext();
return httpContext.User.Identity?.IsAuthenticated ?? false;
}
}
But httpContext.User.Identity?.IsAuthenticated
returns false, even though I am in fact logged in as administrator.
DashboardContext.GetHttpContext()
gives me a context, but it does not appear to be the valid context for my website. Does anyone know what I’m missing?
Here’s how I’m adding it.
app.UseHangfireDashboard("/Admin/hangfire", new DashboardOptions
{
Authorization = new[] { new HangfireAuthorizationFilter() }
});