Exposing hangfire without auth

三世轮回 提交于 2020-05-29 10:47:24

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/45162287/exposing-hangfire-without-auth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!