From a4714544baf848626c75e9851416144cf5adc3d8 Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Tue, 2 Jan 2024 09:09:56 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=A2=9E=E5=8A=A0hangfire=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.ScheduledTask/HangfirePack.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.ScheduledTask/HangfirePack.cs b/Src/Dlhis.ScheduledTask/HangfirePack.cs index e74dda28..dd6c5bac 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,24 @@ namespace Dlhis.ScheduledTask public override void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + //支持可视化界面 ---任何一个用户都能够来访问;所以需要加一道屏障 + app.UseHangfireDashboard("/hangfire", new DashboardOptions() + { + Authorization = new BasicAuthAuthorizationFilter[] { + new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions(){ + SslRedirect=false, + RequireSsl=false, + Users=new BasicAuthAuthorizationUser[]{ + new BasicAuthAuthorizationUser(){ + Login="admin", + PasswordClear="admin" + } + } + }) + } + + }); app.UseHangfireDashboard(); //使用hangfire面板 - //app.UseHangfireServer(); //启动hangfire服务 BackgroundJob.Enqueue(() => Console.WriteLine("This is a background job.")); }