fix:提供hangfire匿名访问并支持所有权限

This commit is contained in:
hardstylewyl 2025-03-19 15:57:58 +08:00
parent 1ce016f945
commit 93814112db
2 changed files with 17 additions and 1 deletions

View File

@ -10,6 +10,7 @@ using SJZY.Expand.ABP.Core.Prometheus;
using SJZY.Expand.ABP.Core.Redis;
using SJZY.Expand.ABP.Core.Swagger;
using SJZY.Track.Application;
using SJZY.Track.Application.Hangfire;
using SJZY.Track.Application.HostServices;
using SJZY.Track.Repository;
using Volo.Abp;
@ -80,7 +81,11 @@ public class SjzyTrackApiModule : AbpModule
app.UseCorsPolicy();
app.UseConfiguredEndpoints();
app.UseAbpSwaggerUI(env);
app.UseHangfireDashboard("/hangfire");
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
DashboardTitle = "轨迹预警任务",
Authorization = new[] { new AnonymousHangfireAuthorizationFilter() }
});
app.UseAbpSerilogEnrichers();
app.UsePrometheus();

View File

@ -0,0 +1,11 @@
using Hangfire.Dashboard;
namespace SJZY.Track.Application.Hangfire;
public class AnonymousHangfireAuthorizationFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
return true;
}
}