Hello, Our project structure is mentioned in this ticket : https://support.abp.io/QA/Questions/4663#answer-3a09d256-58d0-4c55-dc67-7e989f693fb3
We tried to add Hangfire in Admin part of the project (ConfigurateurClient.Admin.HttpApi.Host\AdminHttpApiHostModule.cs).
we called app.UseHangFireDashboard on the last line of OnApplicationInitialization method.
The Admin.HangFire pemrission is well defined in the application.contract layer
But when we want acces to https://localhost:44340/hangfire, we have this message.
Avez-vous des informations sur ce que nous aurions pu manquer pour générer ce type d'erreur ?
ABP Framework version: v7.0.0
UI type: Angular and Blazor (not relevant here)
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): no
17 Answer(s)
-
0
Any chance to send the content of your
OnApplicationInitialization
method? Maybe you have a missing or misordered request-response pipeline. -
0
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); app.UseStaticFiles(); app.UseAbpSecurityHeaders(); app.UseRouting(); app.UseCors(); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseAuthorization(); app.UseSwagger(); app.UseAbpSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Admin API"); var configuration = context.GetConfiguration(); options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); }); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseUnitOfWork(); app.UseConfiguredEndpoints(); app.UseHangfireDashboard("/hangfire", new DashboardOptions { AsyncAuthorization = new[] { new AbpHangfireAuthorizationFilter(enableTenant: true, requiredPermissionName: "Admin.HangFire") } }); }```
-
0
First of all,
UseHangfireDashboard
must be beforeUseConfiguredEndpoints
. However, this is not the problem, I tried to reproduce the problem with the information you provided, but I was unsuccessful, here is my code:ConfigureServices:
... ... ... ... ConfigureHangfire(context, configuration);
ConfigureHangfire:
private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.AddHangfire(config => { config.UseInMemoryStorage(); }); }
OnApplicationInitialization:
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); app.UseStaticFiles(); app.UseAbpSecurityHeaders(); app.UseRouting(); app.UseCors(); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseAuthorization(); app.UseSwagger(); app.UseAbpSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Admin API"); var configuration = context.GetConfiguration(); options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); }); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseUnitOfWork(); app.UseHangfireDashboard("/hangfire", new DashboardOptions { AsyncAuthorization = new[] {new AbpHangfireAuthorizationFilter(enableTenant: true, requiredPermissionName: "Admin.HangFire")} }); app.UseConfiguredEndpoints(); }
When we look at the status code, it returns 401. So, it doesn't see you as authorized, but I think you are logged in. It felt like
CurrentUser.IsAuthenticated
was returning false somehow. Can you confirm this information by debuggingAbpHangfireAuthorizationFilter
-
0
-
0
Yes, because the
CurrentUser
service is resolved fromRequestServices
inIsLoggedIn
method.See: https://github.com/abpframework/abp/blob/ba6ded35524cd4f743f263f33ac37cbc8f238fcd/framework/src/Volo.Abp.HangFire/Volo/Abp/Hangfire/AbpHangfireAuthorizationFilter.cs#L38-L45
-
0
-
0
-
0
I understand, but you're logged in, right? You can see your account information, or if you are logged in as an admin user, you can visit the page where you can see the list of all users and so on, right? If so, I might need to take a closer look at your project. It's hard to say anything directly.
-
0
I logged in using the swagger's built-in function here
And when checking the Authentication server's page, it does show me as logged in.
We can grant you access to the Github repository. Can you confirm this is you ? https://github.com/berkansasmaz Hangfire is being implemented on branch 346-use-hangfire
-
0
I am very happy with the information you have given because I understand the problem. But we need to verify, so can you visit the
/account/login
page and try again after login? -
0
Even after login that way, the issue is still the same.
-
0
Got it, you can grant access to this GitHub account.
-
0
I granted you access. The repo is https://github.com/Manuloc/ConfigurationClient/ on the branch https://github.com/Manuloc/ConfigurationClient/tree/346-use-hangfire
-
0
The problem is that you have installed
Hangfire
inConfigurateurClient.Admin.HttpApi.Host
. If you want to useHangfire
in this project, you should editConfigureAuthentication
similar toConfigurateurClient.Admin.Blazor
, but I don't recommend it. You don't need to openConfigurateurClient.Admin.HttpApi.Host
outside, it can stay internal. Users withConfigurateurClient.Admin.Blazor
admin privileges can access as the UI allows, but they don't need to accessConfigurateurClient.Admin.HttpApi.Host
so you don't need to open its URL outside.As a result, if you want to solve the problem with the least effort and with a more accurate method, you can solve the problem by moving similar codes to
ConfigurateurClient.Admin.Blazor
. I tried it works, you can see the screenshot below. -
0
Thank you for the great news, We will try this solution and come back towards you to confirm the result. Have a nice day
-
0
I moved hangfire to the blazor project and it's working perfectly. Thank you You can mark the issue as resolved
-
0
Closing the issue. Feel free to re-open or create a new issue if you have further questions 😄