-
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:
-
-
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.
[Authorize(ReprosPermissions.TimeSeriesMetaData.Default)]
public class TimeSeriesMetaDataAppService : ApplicationService, ITimeSeriesMetaDataAppService
{
[Authorize(ReprosPermissions.TimeSeriesMetaData.Create)]
public virtual async Task CreateAsync(TimeSeriesMetaDataCreateDto inputDto)
{
//Added record to the database
}
}
public class ResCsvIngestJob : AsyncBackgroundJob, 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
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
https://support.abp.io/QA/Questions/1364/Authorization-in-event-handlers
https://support.abp.io/QA/Questions/1347/Distributed-Events-in-monolith -
0
Thanks Denis
Let's discuss this in your questions. I refunded question credit to jason.