Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I allow access to HangFire Dashboard outside of localhost with basic user login and password?

Tags:

c#

hangfire

I am trying to allow access to HangFire Dashboard from any location. I have added the following code:

app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
    Authorization = new[]
    {
        new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions
        {
            RequireSsl = false,
            SslRedirect = false,
            LoginCaseSensitive = false,
            Users = new[]
            {
                new BasicAuthAuthorizationUser
                {
                    Login = "admin",
                    PasswordClear = "test",
                },
            },
        }),
    },
    IsReadOnlyFunc = (DashboardContext context) => true,
});

But I am getting an error: Error CS7069 Reference to type 'IAuthorizationFilter' claims it is defined in 'Hangfire.Core', but it could not be found

How can I configure the dashboard with simple user access?

like image 203
TK-421 Avatar asked Sep 01 '25 01:09

TK-421


1 Answers

Hangfire.Dashboard.Authorizationis only compatible with .NET Framework.
For .NET Core you should use Hangfire.Dashboard.BasicAuthorization
It only supports the basic authorization, but your piece of code will work as is.

like image 82
ctyar Avatar answered Sep 03 '25 03:09

ctyar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!