Hi
Sorriy, but I could not find what you wrote about on page provided by link. Can you please send link to source of project you talking about?
Also I would want to give more details about by question. I would like to not bind to http client proxy implementation of application services, so calls will be done via HTTP always for any deployment: monolith or microservices. I want to keep event handlers without changes, but also implement Attribute for authentication and authorization, at same way as that done in middleware which is called before endpoint execution. This Attribute will use JWT token provided in app configuration. Execution authorization will be done before event handler call, in the way as it is done in ABP middleware before endpoint execution, so all application services in monolith will be called directly in runtime, as that would be done by another application service during endpoint execution.
In short - I want CurrentUser and CurrentTenant will be provided before event handler execution
Hi @maliming
Can you please explain, how I can do authorization in event handler? I mean that I need to reach the same result as on endpoint execution. Before endpoint executed there is middleware doing authorization. I would like to make that in scope of event handlers
Ok. I will close this question
Please read carefully what I wrote above. My background job in module A needs to get some data from module B. For example - user amount. How can I move Identity module GetUserCount endpoint logic into domain service of module where background job is implemented?
Sure. There is simple example of BackgroundJob in my module
public class UserStatBackgroundJob : IAsyncBackgroundJob<Object>
{
private readonly IUserLookupService<AppUser> _userLookupService;
public UserStatBackgroundJob(IUserLookupService<AppUser> userLookupService)
{
_userLookupService = userLookupService;
}
public async Task ExecuteAsync(Object args)
{
long userCount = await _userLookupService.GetCountAsync();
//usage of userCount
}
}
Yes, I did that. I disbaled UoW via attribute and created UoW for each call of endpoints of other module
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
hi
Don't call application service in event handler. You can call the domain service that without the
Authorization
.
I can not move Application Service logic into Domain Service because endpoint is implemented by another Module. Event Handler in module A pulls some data from module B using its endpoint
There is also one more example with background jobs. For example I need periodical background job which creates stats about users created passed period. Background Job needs to make endpoint call to Idenity module, but it will not able to do that due it is not authorized
So question is how to make authorization prodecure in same way as that done in middleware when endpointcalled?
why do you need authorization? extract the running code part from AppService and move it to a DomainService. then call the domain service method in your handler. And also use it in your AppService as well.
I need authorization because domain make calls to endpoints of another module. I can not move logic of endpoint in module B to domain of module A, which calls endpoint.
For instance, domain may call GET User endpoint in Identity module to get Name of user and use it in own purporse