Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exposing hangfire without auth

Is there a way to expose Hangfire in IIS without having to configure authorization?

In this specific case the dashboard should be open, but when accessing it (not in debug) it returns a 401 code.

like image 788
Yoav Lavi Avatar asked Dec 18 '22 05:12

Yoav Lavi


1 Answers

I think you should be able to write a custom implementation of IDashboardAuthorizationFilter as described in the documentation. Be aware that the default is only local requests to the dashboard are allowed. It's also recommended that you really use authorization and do not publish unauthorized dashboards as it contains sensitive information.

If you still want to do it, try:

Custom DashboardAuthorizationFilter

public class MyAuthorizationFilter : IDashboardAuthorizationFilter
{
    public bool Authorize(DashboardContext context)
    {
        return true;
    }
}

Use it in the configuration of hangfire

app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
    Authorization = new [] { new MyAuthorizationFilter() }
});
like image 130
Philipp Grathwohl Avatar answered Dec 24 '22 00:12

Philipp Grathwohl