ich heruntergeladen habe nu-get Paket Hangfire.Dashboard.Authorization
Hangfire Dashboard-Authorization Config Problem
Ich versuche die OWIN basierte Autorisierung gemäß der Dokumentation wie folgt konfigurieren, aber ich erhalte Intellisense Fehler DashboardOptions.AuthorizationFilters is obsolete please use Authorization property instead
ich auch erhalten Intellisense Fehler The type or namespace AuthorizationFilter and ClaimsBasedAuthorizationFilterd not be found
using Hangfire.Dashboard;
using Hangfire.SqlServer;
using Owin;
using System;
namespace MyApp
{
public class Hangfire
{
public static void ConfigureHangfire(IAppBuilder app)
{
GlobalConfiguration.Configuration
.UseSqlServerStorage(
"ApplicationDbContext",
new SqlServerStorageOptions
{ QueuePollInterval = TimeSpan.FromSeconds(1) });
var options = new DashboardOptions
{
AuthorizationFilters = new[]
{
new AuthorizationFilter { Users = "admin, superuser", Roles = "advanced" },
new ClaimsBasedAuthorizationFilter("name", "value")
}
};
app.UseHangfireDashboard("/hangfire", options);
app.UseHangfireServer();
}
}
}
* UPDATE *
Da die oben nuget Paket funktioniert nicht ich versucht habe meine eigenen benutzerdefinierten Filter zu erstellen:
public class HangfireAuthorizationFilter : IAuthorizationFilter
{
public bool Authorize(IDictionary<string, object> owinEnvironment)
{
// In case you need an OWIN context, use the next line,
// `OwinContext` class is the part of the `Microsoft.Owin` package.
var context = new OwinContext(owinEnvironment);
// Allow all authenticated users to see the Dashboard (potentially dangerous).
return context.Authentication.User.Identity.IsAuthenticated;
}
}
Wie erreiche ich nur Admin-Rollen beschränken das heißt, was die Syntax?
Welche Version von HF Sie verwenden? Bitte zeigen Sie auch die Namespaces an, die Sie in die Klasse importiert haben. – Yogi
@Yogi Hangfire-Kern ist 1.6.1 und die Hangfire.Dashborad.Authorization ist 2.1.0. Ich habe den Beitrag aktualisiert, um Namespaces anzuzeigen. – adam78