Open Closed

Use HangFire with AbpHangfireAuthorizationFilter throw HTTP ERROR 401 #4683


User avatar
0
augustin.couval@manuloc.eu created

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.

And in the swagger logs :

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


2 Answer(s)
  • User Avatar
    0
    berkansasmaz created
    Support Team

    Any chance to send the content of your OnApplicationInitialization method? Maybe you have a missing or misordered request-response pipeline.

  • User Avatar
    0
    augustin.couval@manuloc.eu created
    
        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") }
            });
        }```
    
Made with ❤️ on ABP v8.3.0-preview Updated on July 01, 2024, 12:03