HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.43k stars 1.71k forks source link

Hangfire UI - redirect_uri is http instead of https #2402

Open w-johnny opened 6 months ago

w-johnny commented 6 months ago

Hi, I would like to enable HF UI in my application.

I am using auth0. The problem is when I try to log in in auth0 I am redirected to such a page:

Callback URL mismatch.
The provided redirect_uri is not in the list of allowed callback URLs.
Please go to the [Application Settings page] and make sure you are sending a valid callback url from your application.

This is aligned with auth0 configuration I have and this is expected behavior because the redirect_uri is http instead of https:

&redirect_uri=http%3A%2F%2Fapi-

I allow only https urls.

Here is my configuration:

public class Startup
{
    //...

    public void Configure(IApplicationBuilder app, IHostEnvironment env)
    {
        //...
        app.UseHttpsRedirection();
        //...
        app.UseEndpoints(endpoints =>
        {
            //...

            AddHangfireDashboardIfConfigured(app, endpoints);
        });
    }

    private void AddHangfireDashboardIfConfigured(IApplicationBuilder app, IEndpointRouteBuilder endpoints)
    {
        var configuration = app.ApplicationServices.GetService<IGlobalConfiguration>();
        if (configuration != null)
        {
            endpoints.MapHangfireDashboard(HangfireAuthenticationOptions.HangfireDashboardUrl, new DashboardOptions
            {
                IsReadOnlyFunc = _ =>
                {
                    var authenticationOptions = _configuration
                        .GetSection(HangfireAuthenticationOptions.Authentication)
                        .Get<HangfireAuthenticationOptions>() ?? new HangfireAuthenticationOptions();

                    return authenticationOptions.IsReadonly;
                },
            }).RequireAuthorization(ApplicationAuthorizationServiceCollectionExtensions.HangfireAuthorizationPolicyName);
        }
    }
}

Is there any way to force Hangfire UI to use https instead of http?