Starts in:
1 DAY
13 HRS
9 MIN
42 SEC
Starts in:
1 D
13 H
9 M
42 S
Open Closed

Hangfire Dashboard Authorization is not working #3199


User avatar
0
suraj.kumbhar created
  • ABP Framework version: v5.0.1
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace: 401 error after redirecting to /hangfire page.
  • Steps to reproduce the issue: We have multitenant application and Tenant wise Databases and each tenant has separate hangfire database.

JwtBearerConfigurationHelper.Configure(context, "TestService");

    SwaggerConfigurationHelper.Configure(context, "TestService API");``

context.Services.AddHangfire(config => { config.UseSqlServerStorage(configuration.GetConnectionString("TestService")); });

app.UseHangfireDashboard("/hangfire", new DashboardOptions { AsyncAuthorization = new[] { new AbpHangfireAuthorizationFilter(requiredPermissionName: "Hangfire.Dashboard") } });

After adding an above line not able to see Hangfire Dashboard. Permission is applied for the user but still not able to view Dashboard page.


6 Answer(s)
  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    I suspect that you are not logged in because the error code is 401 (Unauthorized), but I will test the situation and reply to you again.

  • User Avatar
    0
    suraj.kumbhar created

    Thanks for your reply. Its a new service added in Microservice template of services folder to handle background jobs so each tenant there will be separate database. hence please check according to it.

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Any chance of posting a minimally reproducible example so I can reproduce the problem faster?

  • User Avatar
    0
    suraj.kumbhar created

    Hello, We are using Commercial Microservice Template, and in that just added new service everything as per this documentation https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice and in that we have added Hangfire.as per this documentation https://docs.abp.io/en/abp/latest/Background-Jobs-Hangfire without adding dashboard authorization its working but not with Authorization.

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Thank you for the detailed explanation, I will test it as soon as possible.

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Hi, I tested the situation. As you say yes, and this is actually expected.

    Since it is a saas service, even if you do what you want to do, you will have to open the service to outside at the end of the day. Furthermore, to do what you want to do, you will need to pass the token as a parameter to the saas service or prepare a login UI.

    For more information, you can check here: https://medium.com/we-code/hangfire-dashboard-and-jwt-authentication-751aae3bcd4a

    My suggestion is not to add hangfire to saas service or other services. You can create a separate host application for this (similar to auth-server), then set the necessary dependencies and access hangfire from there.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06