From 8fe7a0c1bda0ad27f112153a10ae06c70dc9b91d Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 2 Jan 2024 21:58:41 +0800 Subject: [PATCH] fix auth --- .../Dlhis.ScheduledTask.csproj | 5 ++--- Src/Dlhis.ScheduledTask/HangfirePack.cs | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj index 6aa4680e..b44ece5f 100644 --- a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj +++ b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj @@ -17,11 +17,10 @@ - + - + - diff --git a/Src/Dlhis.ScheduledTask/HangfirePack.cs b/Src/Dlhis.ScheduledTask/HangfirePack.cs index e74dda28..040d4e0d 100644 --- a/Src/Dlhis.ScheduledTask/HangfirePack.cs +++ b/Src/Dlhis.ScheduledTask/HangfirePack.cs @@ -1,4 +1,5 @@ using Hangfire; +using Hangfire.Dashboard.BasicAuthorization; using Hangfire.MySql; using Kurisu.AspNetCore.Startup; @@ -28,8 +29,25 @@ namespace Dlhis.ScheduledTask public override void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - app.UseHangfireDashboard(); //使用hangfire面板 - //app.UseHangfireServer(); //启动hangfire服务 + app.UseHangfireDashboard("/hangfire", new DashboardOptions + { + AppPath = null, + DashboardTitle = "hangfire", + Authorization = new[] + { + new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions + { + Users = new [] + { + new BasicAuthAuthorizationUser + { + Login ="admin", + PasswordClear = "zxc111" + } + } + }) + } + }); BackgroundJob.Enqueue(() => Console.WriteLine("This is a background job.")); }