diff --git a/WebCms/App_Data/Models/all.dll.path b/WebCms/App_Data/Models/all.dll.path index 4e1f901..623df95 100644 --- a/WebCms/App_Data/Models/all.dll.path +++ b/WebCms/App_Data/Models/all.dll.path @@ -1 +1 @@ -C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.rnwtj1wz.dll \ No newline at end of file +C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.agsib7ro.dll \ No newline at end of file diff --git a/WebCms/App_Start/HangfireStartup.cs b/WebCms/App_Start/HangfireStartup.cs index 186857a..13c09f6 100644 --- a/WebCms/App_Start/HangfireStartup.cs +++ b/WebCms/App_Start/HangfireStartup.cs @@ -1,9 +1,13 @@ -using System.Web.Hosting; +using System.Linq; +using System.Web; +using System.Web.Hosting; using Hangfire; +using Hangfire.Dashboard; using LeafWeb.WebCms.App_Start; using LeafWeb.WebCms.Services.PiscalQueue; using Microsoft.Owin; using Owin; +using Umbraco.Core.Security; using Umbraco.Web; using ConfigurationManager = System.Configuration.ConfigurationManager; @@ -27,7 +31,15 @@ namespace LeafWeb.WebCms.App_Start public void Configuration(IAppBuilder app) { - app.UseHangfireDashboard(); + app.UseHangfireDashboard("/hangfire", + new DashboardOptions + { + Authorization = new IDashboardAuthorizationFilter[] + { + //new LocalRequestsOnlyAuthorizationFilter(), + new UmbracoAuthorizationFilter() + } + }); SetupRecurringJobs(); } @@ -45,6 +57,26 @@ namespace LeafWeb.WebCms.App_Start } } + public class UmbracoAuthorizationFilter : IDashboardAuthorizationFilter + { + public bool Authorize(DashboardContext context) + { + // Ensure umbraco user if possible. + var http = new HttpContextWrapper(HttpContext.Current); + var ticket = http.GetUmbracoAuthTicket(); + http.AuthenticateCurrentRequest(ticket, true); + + var user = UmbracoContext.Current.Security.CurrentUser; + + if (user != null && user.AllowedSections.Contains("developer")) + { + return true; + } + + return false; + } + } + // http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html public class ApplicationPreload : IProcessHostPreloadClient { diff --git a/WebCms/WebCms.csproj b/WebCms/WebCms.csproj index b93f51d..2e31e7b 100644 --- a/WebCms/WebCms.csproj +++ b/WebCms/WebCms.csproj @@ -774,6 +774,7 @@ + Web.config