public static IEndpointConventionBuilder MapHangfireDashboard( [NotNull] this IEndpointRouteBuilder endpoints, [CanBeNull] DashboardOptions options = null, [CanBeNull] JobStorage storage = null) { return(MapHangfireDashboard(endpoints, "/hangfire", options, storage)); }
public static IEndpointConventionBuilder MapHangfireDashboard( [NotNull] this IEndpointRouteBuilder endpoints, [NotNull] string pattern, [CanBeNull] DashboardOptions options = null, [CanBeNull] JobStorage storage = null) { if (endpoints == null) { throw new ArgumentNullException(nameof(endpoints)); } if (pattern == null) { throw new ArgumentNullException(nameof(pattern)); } var app = endpoints.CreateApplicationBuilder(); HangfireServiceCollectionExtensions.ThrowIfNotConfigured(app.ApplicationServices); var services = app.ApplicationServices; storage = storage ?? services.GetRequiredService <JobStorage>(); options = options ?? services.GetService <DashboardOptions>() ?? new DashboardOptions(); options.TimeZoneResolver = options.TimeZoneResolver ?? services.GetService <ITimeZoneResolver>(); var routes = app.ApplicationServices.GetRequiredService <Dashboard.RouteCollection>(); var pipeline = app .UsePathBase(pattern) .UseMiddleware <AspNetCoreDashboardMiddleware>(storage, options, routes) .Build(); return(endpoints.Map(pattern + "/{**path}", pipeline)); }
public static IEndpointConventionBuilder MapHangfireDashboardWithAuthorizationPolicy( [NotNull] this IEndpointRouteBuilder endpoints, [NotNull] string authorizationPolicyName, [NotNull] string pattern = "/hangfire", [CanBeNull] DashboardOptions options = null, [CanBeNull] JobStorage storage = null) { if (endpoints == null) { throw new ArgumentNullException(nameof(endpoints)); } if (authorizationPolicyName == null) { throw new ArgumentNullException(nameof(authorizationPolicyName)); } options = options ?? new DashboardOptions(); // We don't require the default LocalRequestsOnlyAuthorizationFilter since we provide our own policy options.Authorization = Enumerable.Empty <IDashboardAuthorizationFilter>(); options.AsyncAuthorization = Enumerable.Empty <IDashboardAsyncAuthorizationFilter>(); return(endpoints .MapHangfireDashboard(pattern, options, storage) .RequireAuthorization(authorizationPolicyName)); }
public void Configuration(IAppBuilder app) { var authorizationFilter = new BasicAuthAuthorizationFilter( new BasicAuthAuthorizationFilterOptions { // Require secure connection for dashboard RequireSsl = true, // Case sensitive login checking LoginCaseSensitive = true, // Users Users = new[] { new BasicAuthAuthorizationUser { Login = "******", PasswordClear = "passW0rd!" } } }); var options = new DashboardOptions { AuthorizationFilters = new IAuthorizationFilter[] { authorizationFilter } }; GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection"); app.UseHangfireDashboard("/hangfire", options); app.UseHangfireServer(); ConfigureAuth(app); }
public void ConfigureOwin(IAppBuilder app, IUnityContainer container) { JobStorage.Current = CreateJobStorage(Stage.ConfigureOwin); // Configure Hangfire dashboard var securityService = container.Resolve<ISecurityService>(); var moduleInitializerOptions = container.Resolve<IModuleInitializerOptions>(); var appPath = "/" + moduleInitializerOptions.RoutePrefix; var authorizationFilters = new[] { new PermissionBasedAuthorizationFilter(securityService) { Permission = PredefinedPermissions.BackgroundJobsManage } }; var dashboardOptions = new DashboardOptions { AppPath = appPath, AuthorizationFilters = authorizationFilters }; app.UseHangfireDashboard(appPath + "hangfire", dashboardOptions); // Configure Hangfire server if (_options.StartServer) { app.UseHangfireServer(new BackgroundJobServerOptions { Activator = new UnityJobActivator(container) }); } }
public void ConfigureHangFire(IAppBuilder app) { var storageOptions = new SqlServerStorageOptions { InvisibilityTimeout = TimeSpan.FromHours(2), QueuePollInterval = TimeSpan.FromMinutes(15.0) }; GlobalConfiguration.Configuration .UseSqlServerStorage("TrainingManagerDb", storageOptions); // case msmq installed /*GlobalConfiguration.Configuration .UseSqlServerStorage("TrainingManagerDb") .UseMsmqQueues(@".\hangfire-{0}");*/ var dashboardOptions = new DashboardOptions { AuthorizationFilters = new[] { new AuthorizationFilter { Roles = AppConstants.UserRole.Administrator } } }; app.UseHangfireDashboard("/hangfire", dashboardOptions); var jobServerOptions = new BackgroundJobServerOptions { WorkerCount = 1 }; app.UseHangfireServer(jobServerOptions); RecurringJob.AddOrUpdate(() => UpdateDaemon.ScheduledCatalogsUpdate(), Cron.Hourly); }
public void Configuration(IAppBuilder app) { HangfireConfiguration.Register(); var options = new DashboardOptions { AuthorizationFilters = new [] { new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions { RequireSsl = true, LoginCaseSensitive = true, Users = new [] { new BasicAuthAuthorizationUser { Login = "******", PasswordClear = "D3v3L0pM3nT" } } }), } }; app.UseHangfireDashboard("/hangfire", options); app.UseHangfireServer(); }
/// <summary> /// Adds Dashboard UI middleware to the OWIN request processing pipeline under /// the specified path and the given options, for the <see cref="JobStorage.Current"/> /// storage. /// </summary> /// <param name="builder">OWIN application builder.</param> /// <param name="pathMatch">Path prefix for middleware to use, e.g. "/hangfire".</param> /// <param name="options">Options for Dashboard UI.</param> /// /// <exception cref="ArgumentNullException"><paramref name="builder"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="pathMatch"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="options"/> is null.</exception> /// /// <remarks> /// Please see <see cref="AppBuilderExtensions"/> for details and examples. /// </remarks> public static IAppBuilder UseHangfireDashboard( [NotNull] this IAppBuilder builder, [NotNull] string pathMatch, [NotNull] DashboardOptions options) { return(builder.UseHangfireDashboard(pathMatch, options, JobStorage.Current)); }
public static IApplicationBuilder UseHangfireDashboard( [NotNull] this IApplicationBuilder app, [NotNull] string pathMatch = "/hangfire", [CanBeNull] DashboardOptions options = null, [CanBeNull] JobStorage storage = null) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (pathMatch == null) { throw new ArgumentNullException(nameof(pathMatch)); } HangfireServiceCollectionExtensions.ThrowIfNotConfigured(app.ApplicationServices); var services = app.ApplicationServices; storage = storage ?? services.GetRequiredService <JobStorage>(); options = options ?? services.GetService <DashboardOptions>() ?? new DashboardOptions(); options.TimeZoneResolver = options.TimeZoneResolver ?? services.GetService <ITimeZoneResolver>(); var routes = app.ApplicationServices.GetRequiredService <RouteCollection>(); app.Map(new PathString(pathMatch), x => x.UseMiddleware <AspNetCoreDashboardMiddleware>(storage, options, routes)); return(app); }
public static IAppBuilder UseHangfireDashboard( [NotNull] this IAppBuilder builder, [NotNull] string pathMatch, [NotNull] DashboardOptions options, [NotNull] JobStorage storage) { if (builder == null) { throw new ArgumentNullException("builder"); } if (pathMatch == null) { throw new ArgumentNullException("pathMatch"); } if (options == null) { throw new ArgumentNullException("options"); } if (storage == null) { throw new ArgumentNullException("storage"); } SignatureConversions.AddConversions(builder); builder.Map(pathMatch, subApp => subApp .UseOwin() .UseHangfireDashboard(options, storage, DashboardRoutes.Routes)); return(builder); }
/// <summary> /// Adds Dashboard UI middleware to the OWIN request processing pipeline with the /// specified parameters and antiforgery service. /// </summary> /// <param name="builder">OWIN application builder.</param> /// <param name="pathMatch">Path prefix for middleware to use, e.g. "/hangfire".</param> /// <param name="options">Options for Dashboard UI.</param> /// <param name="storage">Job storage to use by Dashboard IO.</param> /// <param name="antiforgery">Antiforgery service.</param> /// /// <exception cref="ArgumentNullException"><paramref name="builder"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="pathMatch"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="options"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="storage"/> is null.</exception> /// /// <remarks> /// Please see <see cref="AppBuilderExtensions"/> for details and examples. /// </remarks> public static IAppBuilder UseHangfireDashboard( [NotNull] this IAppBuilder builder, [NotNull] string pathMatch, [NotNull] DashboardOptions options, [NotNull] JobStorage storage, [CanBeNull] IOwinDashboardAntiforgery antiforgery) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (pathMatch == null) { throw new ArgumentNullException(nameof(pathMatch)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (storage == null) { throw new ArgumentNullException(nameof(storage)); } SignatureConversions.AddConversions(builder); builder.Map(pathMatch, subApp => subApp .UseOwin() .UseHangfireDashboard(options, storage, DashboardRoutes.Routes, antiforgery)); return(builder); }
public static IEndpointConventionBuilder MapHangfireDashboardWithAuthorizationPolicy( [NotNull] this IEndpointRouteBuilder endpoints, [NotNull] string authorizationPolicyName, [CanBeNull] DashboardOptions options = null, [CanBeNull] JobStorage storage = null) { return(MapHangfireDashboardWithAuthorizationPolicy(endpoints, authorizationPolicyName, "/hangfire", options, storage)); }
/// <summary> /// Adds Dashboard UI middleware to the OWIN request processing pipeline with the /// specified parameters. /// </summary> /// <param name="builder">OWIN application builder.</param> /// <param name="pathMatch">Path prefix for middleware to use, e.g. "/hangfire".</param> /// <param name="options">Options for Dashboard UI.</param> /// <param name="storage">Job storage to use by Dashboard IO.</param> /// /// <exception cref="ArgumentNullException"><paramref name="builder"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="pathMatch"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="options"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="storage"/> is null.</exception> /// /// <remarks> /// Please see <see cref="AppBuilderExtensions"/> for details and examples. /// </remarks> public static IAppBuilder UseHangfireDashboard( [NotNull] this IAppBuilder builder, [NotNull] string pathMatch, [NotNull] DashboardOptions options, [NotNull] JobStorage storage) { return(builder.UseHangfireDashboard(pathMatch, options, storage, null)); }
// Install the Hangfire.Dashboard.Authorization NuGet package first. public void Configuration(IAppBuilder app) { // GlobalConfiguration usage was removed for clarity. var options = new DashboardOptions { AuthorizationFilters = new [] { new AuthorizationFilter { Roles = "admin" }, } }; app.UseHangfireDashboard("/hangfire", options); }
public static IApplicationBuilder UseHangfireDashboard(this IApplicationBuilder builder, IServiceInfo serviceInfo) { var options = new DashboardOptions { AppPath = $"/{serviceInfo.ShortName}/hangfire", DashboardTitle = $"{serviceInfo.Description}任务控制台", DisplayStorageConnectionString = false }; builder.UseHangfireDashboard($"/{serviceInfo.ShortName}/hangfire", options); return(builder); }
public static IApplicationBuilder UseHangfireDashboard( [NotNull] this IApplicationBuilder app, [CanBeNull] string pathMatch = "/hangfire", [CanBeNull] Action <DashboardOptions> setup = null, [CanBeNull] JobStorage storage = null) { Check.NotNull(app, nameof(app)); var options = new DashboardOptions(); setup?.Invoke(options); return(app.UseHangfireDashboard(pathMatch: pathMatch, options: options, storage: storage)); }
public static DashboardOptions UseAuthorizations( [NotNull] this DashboardOptions options, [NotNull] IEnumerable <IDashboardAuthorizationFilter> authorizationFilters) { Check.NotNull(options, nameof(options)); Check.NotNull(authorizationFilters, nameof(authorizationFilters)); List <IDashboardAuthorizationFilter> filters = new List <IDashboardAuthorizationFilter>(); filters.AddRange(authorizationFilters); options.Authorization = filters; return(options); }
public static DashboardOptions AddAuthorization( [NotNull] this DashboardOptions options, [NotNull] IDashboardAuthorizationFilter authorizationFilter) { Check.NotNull(options, nameof(options)); Check.NotNull(authorizationFilter, nameof(authorizationFilter)); List <IDashboardAuthorizationFilter> filters = new List <IDashboardAuthorizationFilter>(); filters.AddRange(options.Authorization); filters.AddIfNotContains(authorizationFilter); options.Authorization = filters; return(options); }
public static DashboardOptions UseAuthorization( [NotNull] this DashboardOptions options, [NotNull] IDashboardAuthorizationFilter authorizationFilter) { Check.NotNull(options, nameof(options)); Check.NotNull(authorizationFilter, nameof(authorizationFilter)); List <IDashboardAuthorizationFilter> filters = new List <IDashboardAuthorizationFilter> { authorizationFilter }; options.Authorization = filters; return(options); }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); GlobalConfiguration.Configuration.UseSqlServerStorage("HangFireDB"); var options = new DashboardOptions { AuthorizationFilters = new [] { new ClaimsBasedAuthorizationFilter(ClaimTypes.Role, "Admin") } }; app.UseHangfireDashboard("/hangfire", options); app.UseHangfireServer(); RecurringJob.AddOrUpdate(() => SessionCounter.CreateTables(), Cron.Daily); RecurringJob.AddOrUpdate(() => SessionCounter.RegisterUserSessions(), Cron.Minutely); }
public static IEndpointConventionBuilder MapHangfireDashboardWithAuthorizationPolicy( [NotNull] this IEndpointRouteBuilder endpoints, [NotNull] string authorizationPolicyName, [NotNull] string pattern, [CanBeNull] DashboardOptions options = null, [CanBeNull] JobStorage storage = null) { if (options == null) { options = new DashboardOptions() { Authorization = new List <IDashboardAuthorizationFilter>() // We don't require the default LocalHost only filter since we provide our own policy }; } return(endpoints .MapHangfireDashboard(pattern, options, storage) .RequireAuthorization(authorizationPolicyName)); }
public void Configuration(IAppBuilder app) { var options = new DashboardOptions { AuthorizationFilters = new[] { new LocalRequestsOnlyAuthorizationFilter() } }; app.UseHangfireDashboard("/hangfire", options); /* app.UseHangfire(config => { config.UseSqlServerStorage("DbConnection"); config.UseServer(); }); app.UseHangfireServer();*/ }
public void Configuration(IAppBuilder app) { var options = new DashboardOptions { AppPath = VirtualPathUtility.ToAbsolute("~"), AuthorizationFilters = new[] { new HangFireAuthorizationFilter() } }; app.UseHangfireDashboard("/private/hangfire", options); app.UseHangfireServer(); //InfoPageConfigurator.Configure(app, // x => // { // x.BaseUrl = "custom-info"; // x.ApplicationName = "WLOG"; // }); }
public static IApplicationBuilder UseHangfireDashboard(this IApplicationBuilder builder, IServiceInfo serviceInfo, params Authorize[] authorize) { var options = new DashboardOptions { AppPath = $"/{serviceInfo.ShortName}/hangfire", DashboardTitle = $"{serviceInfo.Description}任务控制台", DisplayStorageConnectionString = false }; if (authorize.Any()) { options.Authorization = authorize.Select(s => new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions { Users = new[] { new BasicAuthAuthorizationUser { Login = s.Login, PasswordClear = s.Password } } })).ToArray(); } builder.UseHangfireDashboard($"/{serviceInfo.ShortName}/hangfire", options); return(builder); }
public void Configuration(IAppBuilder app) { // GlobalConfiguration usage was removed for clarity. var options = new DashboardOptions { AppPath = "/app" }; app.UseHangfireDashboard("/hangfire", options); }