From d5edbaed5c7d00f19eedd409dd9fcd4686dba6b9 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Thu, 14 May 2020 09:12:40 +0800 Subject: [PATCH] 1.0.0.514-1 Former-commit-id: 72685838a4811c628187b92e318de3ad71b1bbaa --- projects/Infrastructure/Infrastructure.csproj | 14 +++++++------- projects/IoT.Shared/IoT.Shared.csproj | 6 +++--- projects/IoTNode/IoTNode.csproj | 2 +- .../CustomDashboardAuthorizationFilter.cs | 13 +++++++++++++ projects/IoTNode/Startup.cs | 19 +++++++------------ projects/IoTNode/appsettings.json | 4 ++++ projects/UserCenter/UserCenter.csproj | 4 ++-- projects/Version.cs | 2 +- projects/WebMVC/WebMVC.csproj | 2 +- projects/WebSPA/WebSPA.csproj | 2 +- 10 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 projects/IoTNode/Services/CustomDashboardAuthorizationFilter.cs diff --git a/projects/Infrastructure/Infrastructure.csproj b/projects/Infrastructure/Infrastructure.csproj index 7f38957a..df0365e0 100644 --- a/projects/Infrastructure/Infrastructure.csproj +++ b/projects/Infrastructure/Infrastructure.csproj @@ -17,14 +17,14 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - - - - + + + + + + diff --git a/projects/IoT.Shared/IoT.Shared.csproj b/projects/IoT.Shared/IoT.Shared.csproj index a21e48f8..e4b386ac 100644 --- a/projects/IoT.Shared/IoT.Shared.csproj +++ b/projects/IoT.Shared/IoT.Shared.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/projects/IoTNode/IoTNode.csproj b/projects/IoTNode/IoTNode.csproj index ec3d817c..aba2648b 100644 --- a/projects/IoTNode/IoTNode.csproj +++ b/projects/IoTNode/IoTNode.csproj @@ -13,7 +13,7 @@ - + diff --git a/projects/IoTNode/Services/CustomDashboardAuthorizationFilter.cs b/projects/IoTNode/Services/CustomDashboardAuthorizationFilter.cs new file mode 100644 index 00000000..b5723cc1 --- /dev/null +++ b/projects/IoTNode/Services/CustomDashboardAuthorizationFilter.cs @@ -0,0 +1,13 @@ +using Hangfire.Annotations; +using Hangfire.Dashboard; + +namespace IoTNode.Services +{ + public class CustomDashboardAuthorizationFilter : IDashboardAuthorizationFilter + { + public bool Authorize([NotNull] DashboardContext context) + { + return context.GetHttpContext().User.Identity.IsAuthenticated; + } + } +} \ No newline at end of file diff --git a/projects/IoTNode/Startup.cs b/projects/IoTNode/Startup.cs index 8e93b9d3..a21c1508 100644 --- a/projects/IoTNode/Startup.cs +++ b/projects/IoTNode/Startup.cs @@ -47,20 +47,15 @@ namespace IoTNode public override void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { base.Configure(app, env, loggerFactory); - app.UseHangfireDashboard(pathMatch: "/job"); - app.UseHangfireServer(); + var options = new DashboardOptions + { + Authorization = new[] { new CustomDashboardAuthorizationFilter() } + }; + + app.UseHangfireDashboard("/job", options); - //Task.Run(() => - //{ - // using var scope = app.ApplicationServices.CreateScope(); - // var timerRepo = scope.ServiceProvider.GetService>(); - // var timers = timerRepo.ReadOnlyTable().Where(o => o.Scene.NodeId != null).ToList(); - // foreach (var timer in timers) - // { - // RecurringJob.AddOrUpdate(timer.Id.ToString(), o => o.TimerHanle(timer.Id), timer.Cron, TimeZoneInfo.Local); - // } - //}); + app.UseHangfireServer(); } } } \ No newline at end of file diff --git a/projects/IoTNode/appsettings.json b/projects/IoTNode/appsettings.json index 9aa6feb5..13c74b12 100644 --- a/projects/IoTNode/appsettings.json +++ b/projects/IoTNode/appsettings.json @@ -25,5 +25,9 @@ "key": "111111111111111111111111", "issuer": "111111111111111111111111", "audience": "111111111111111111111111" + }, + "auth": { + "usr": "admin", + "pwd": "admin" } } \ No newline at end of file diff --git a/projects/UserCenter/UserCenter.csproj b/projects/UserCenter/UserCenter.csproj index 4cef0efd..79b5a1b5 100644 --- a/projects/UserCenter/UserCenter.csproj +++ b/projects/UserCenter/UserCenter.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/projects/Version.cs b/projects/Version.cs index f1dba7d9..d1a70247 100644 --- a/projects/Version.cs +++ b/projects/Version.cs @@ -1,4 +1,4 @@ using System.Reflection; [assembly: AssemblyVersion("1.0.0.*")] -[assembly: AssemblyInformationalVersion("1.0.0.514")] \ No newline at end of file +[assembly: AssemblyInformationalVersion("1.0.0.514-1")] \ No newline at end of file diff --git a/projects/WebMVC/WebMVC.csproj b/projects/WebMVC/WebMVC.csproj index e84ff198..e58c9bba 100644 --- a/projects/WebMVC/WebMVC.csproj +++ b/projects/WebMVC/WebMVC.csproj @@ -6,6 +6,6 @@ - + \ No newline at end of file diff --git a/projects/WebSPA/WebSPA.csproj b/projects/WebSPA/WebSPA.csproj index e84ff198..e58c9bba 100644 --- a/projects/WebSPA/WebSPA.csproj +++ b/projects/WebSPA/WebSPA.csproj @@ -6,6 +6,6 @@ - + \ No newline at end of file