Open Closed

AsyncBackgroundJob using AppService with Authorize attributes #1371

jason.smith created
  • ABP Framework version: v3.2.1
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace: none
  • Steps to reproduce the issue:
    1. AsyncBackgroundJob that calls an AppService with and [Authorize] attribute on the method called.

Looking for the correct method to supply the calling users permissions / authorisations to a background job so that long running actions can be performed on behalf of that user.

public class TimeSeriesMetaDataAppService : ApplicationService, ITimeSeriesMetaDataAppService
    public virtual async Task<TimeSeriesMetaDataDto> CreateAsync(TimeSeriesMetaDataCreateDto inputDto)
        //Added record to the database

public class ResCsvIngestJob : AsyncBackgroundJob<ResCsvIngestArgs>, ITransientDependency
    public ResCsvIngestJob(
        ITimeSeriesMetaDataAppService timeSeriesMetaDataAppService)
        _timeSeriesMetaDataAppService = timeSeriesMetaDataAppService;

    public override async Task ExecuteAsync(ResCsvIngestArgs args)
        //How do I call the following without getting the auth exception?
        await _timeSeriesMetaDataAppService.CreateAsync(new TimeSeriesMetaDataCreateDto());

2 Answer(s)
  • 1
    Denis created

    I have similar issue. I have 2 modules A and B. Module A has Background Job which calls endpoint in module B. Background Job gets exception AbpAuthoizationException because endpoint is protected with permission

    My qestions about that

  • 0
    maliming created
    Support Team

    Thanks Denis

    Let's discuss this in your questions. I refunded question credit to jason.