Dashboard Authorization obsolete

authorization
dashboard
Tags: #<Tag:0x00007f499b3b4098> #<Tag:0x00007f499ae035e0>

#1

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


#2

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:


#3

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


#4

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


#5

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


#6

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


#7

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


#8

Hello use this way,

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


#9

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() }

#10

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: