Configure hangfire dashboard to use umbraco authorization
This commit is contained in:
@@ -1 +1 @@
|
|||||||
C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.rnwtj1wz.dll
|
C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.agsib7ro.dll
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
using System.Web.Hosting;
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Hosting;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
|
using Hangfire.Dashboard;
|
||||||
using LeafWeb.WebCms.App_Start;
|
using LeafWeb.WebCms.App_Start;
|
||||||
using LeafWeb.WebCms.Services.PiscalQueue;
|
using LeafWeb.WebCms.Services.PiscalQueue;
|
||||||
using Microsoft.Owin;
|
using Microsoft.Owin;
|
||||||
using Owin;
|
using Owin;
|
||||||
|
using Umbraco.Core.Security;
|
||||||
using Umbraco.Web;
|
using Umbraco.Web;
|
||||||
using ConfigurationManager = System.Configuration.ConfigurationManager;
|
using ConfigurationManager = System.Configuration.ConfigurationManager;
|
||||||
|
|
||||||
@@ -27,7 +31,15 @@ namespace LeafWeb.WebCms.App_Start
|
|||||||
|
|
||||||
public void Configuration(IAppBuilder app)
|
public void Configuration(IAppBuilder app)
|
||||||
{
|
{
|
||||||
app.UseHangfireDashboard();
|
app.UseHangfireDashboard("/hangfire",
|
||||||
|
new DashboardOptions
|
||||||
|
{
|
||||||
|
Authorization = new IDashboardAuthorizationFilter[]
|
||||||
|
{
|
||||||
|
//new LocalRequestsOnlyAuthorizationFilter(),
|
||||||
|
new UmbracoAuthorizationFilter()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
SetupRecurringJobs();
|
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
|
// http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html
|
||||||
public class ApplicationPreload : IProcessHostPreloadClient
|
public class ApplicationPreload : IProcessHostPreloadClient
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -774,6 +774,7 @@
|
|||||||
<Content Include="Views\Partials\Grid\Editors\Base.cshtml" />
|
<Content Include="Views\Partials\Grid\Editors\Base.cshtml" />
|
||||||
<Content Include="Views\Partials\Grid\Bootstrap3-Fluid.cshtml" />
|
<Content Include="Views\Partials\Grid\Bootstrap3-Fluid.cshtml" />
|
||||||
<Content Include="Views\Partials\Grid\Bootstrap2-Fluid.cshtml" />
|
<Content Include="Views\Partials\Grid\Bootstrap2-Fluid.cshtml" />
|
||||||
|
<Content Include="Views\MacroPartials\LeafInputQueueDetails.cshtml" />
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>Web.config</DependentUpon>
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
Reference in New Issue
Block a user