private static void ValidateOptions(HangfireDashboardOptions options)
 {
     if (options.Enabled && (!AreCredentialsValid(options) || !IsRouteValid(options)))
     {
         throw new InvalidOperationException($"Unable to perform {nameof(UseOptionsBasedHangfireDashboard)}. Options invalid.");
     }
 }
 private static void UseDashboardWithBasicAuth(IApplicationBuilder builder, HangfireDashboardOptions options)
 {
     builder.UseHangfireDashboard(
         options.Route,
         new DashboardOptions
     {
         Authorization = new[]
         {
             new HangfireBasicAuthFilter(options),
         },
     });
 }
Beispiel #3
0
 public HangfireBasicAuthFilter(HangfireDashboardOptions options)
 {
     _options = options;
 }
 private static bool IsRouteValid(HangfireDashboardOptions options)
 {
     return(!string.IsNullOrWhiteSpace(options.Route) && options.Route.StartsWith("/", StringComparison.InvariantCultureIgnoreCase));
 }
 private static bool AreCredentialsValid(HangfireDashboardOptions options)
 {
     return(!string.IsNullOrWhiteSpace(options.Username) && !string.IsNullOrWhiteSpace(options.Password));
 }