Dashboard Authorization obsolete

I have setup Dashboard Authorization as suggested in the documentation (http://docs.hangfire.io/en/latest/configuration/using-dashboard.html#configuring-authorization)

However, I’m getting the following warnings:
Warning: ‘DashboardOptions.AuthorizationFilters’ is obsolete: ‘Please use Authorization property instead. Will be removed in 2.0.0.’
Warning: ‘IAuthorizationFilter’ is obsolete: ‘Please use IDashboardAuthorizationFilter instead. Will be removed in 2.0.0.’

I’m unsure how to make the correct changes to the Dashboard Authorization. Can anyone help?

Other threas: AuthorizationFilters

hey mma

It probably means they will phase it out in future releases. This is what I have

    public class HangfireAuthorization : IDashboardAuthorizationFilter
{
    public bool Authorize([NotNull] DashboardContext context)
    {
        if (HttpContext.Current.User!= null &&  HttpContext.Current.User.Identity.IsAuthenticated)
        {
            return HttpContext.Current.User.Identity.Name.Equals("SystemAdmin");
        }
        return false;
    }
}

Let me know if it helps :+1:

For asp.net core GetHttpContext() extension method can be used.

1 Like

Hi,

We’re trying to implement with IDashboardAuthorizationFilter a custom one to use the IdentityServer3 has the auth provider… but with no success.

Even with the cookies configuration added we can’t access into the logged account. We already tried with OwinContext:

var owinContext = new OwinContext(context.GetOwinEnvironment());

with logged admin account (idsvr.session cookie assinged) we can’t get any information on the filter regarding the authenticated user.

Can you provide any suggestion?

Thanks

2 Likes

I’m pretty much trying to do the samething, integrating it with identityserver3 with no success.

1 Like

Check this post it may assist in implementation Using bearer auth token

thanks vikramjb. However, where do I apply the Authorization property?
Thanks in advance.
/Morten

Hello use this way,

app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
Authorization = new [] { new HangfireAuthorization () }
});

thanks. for reference I ended up creating a HangfireAuthorization class

public class HangfireAuthorization : IDashboardAuthorizationFilter
{
    public bool Authorize([NotNull] DashboardContext context)
    {
       ...

and then linking it up like this:

  public static void ConfigureHangfire(IAppBuilder app)
  {
        ...
  	app.UseHangfireDashboard("/hangfire", new DashboardOptions
  	{
  		    ...
  	    Authorization = new[] { new HangfireAuthorization() }

If any one needs the functionality provided by the Hangfire.Dashboard.Authorization package but that’s compatible with the latest Hangfire.Core version (1.7 as of today) I created the following simpler replacement which can be used instead until that package is updated to work with the latest Hangfire version:

1 Like

@AbrahamLopez10 thanks! just what I was looking for.
Browser promote for credentials.