Hangfire Dashboard Authentication
See original GitHub issueHello,
Just trying to get the Hangfire dashboard functioning with Abp permissions.
i declared the Authorization Filter in a seperate class in my web project.
namespace Portal.Web
{
public class HangfireAuthorizationFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
using (var permissionChecker = IocManager.Instance.ResolveAsDisposable<IPermissionChecker>())
{
return permissionChecker.Object.IsGranted(PermissionNames.Pages);
}
}
}
}
and then call the filter in the Startup class of the web project
app.UseHangfireDashboard("/Tools/BackgroundJobs", new DashboardOptions
{
Authorization = new[] { new HangfireAuthorizationFilter() }
});
The problem i have is that the Authorize filter always returns false. If i manually change the method to
return permissionChecker.Object.IsGranted(1,PermissionNames.Pages);
Where 1 is the userId of a valid user that has that permission granted, it works fine.
Im not too sure where it pulls the user information from for this PermissionChecker, but when i put a breakpoint in the Authorize method i can see AbpSession is a property of PermissionChecker, but all the values are set to null, even though i am logged in.
Any suggestions as to what could be causing this?
I am running Abp v0.10.3 Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
@hikalkan Yeah i have moved the
UserHangFireDashboard
afterUseCookieAuthentication
and i can confirm it works as expected now. I will make use of the new class when its available. Many Thanks!BTW, I added an AbpHangfireAuthorizationFilter class to Abp.HangFire nuget package: https://github.com/aspnetboilerplate/aspnetboilerplate/commit/e4c61d670a9814eb23ef543510cc56c91915aafa Will be available in the next release.