Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "Aitor"

Greetings everyone, please I request your help with this case. We have a problem applying the concept of User Impersonate, which works correctly in the development environment, but in a production environment mounted on AWS Elastic Beanstalk and NGINX as a web server, it does not work because the cache loses the data of the user who performs the impersonation. The error we get is the following:

Abp.Authorization.AbpAuthorizationException: The current tenant is different from the given tenant. AbpSession.TenantId: , given tenant id: 1 in PARPlatform.Web.Controllers.TokenAuthController.ImpersonatedAuthenticate(String impersonationToken) in /builds/webcreeklab/platformpar/aspnet-core/src/PARPlatform.Web.Core/Controllers/TokenAuthController.cs:line 402 at lambda_method4875(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object handler, Object[] arguments) Caller, TaskInTakerController, LastActionTask) Next State, Scope, Object State, Boolean is Completed)

And that happens in this method of the ImpersonationManager class where AbpSession.TenantId is NULL:

private void CheckCurrentTenant(int? tenantId) { if (AbpSession.TenantId != tenantId) { throw new Exception($"Current tenant is different than given tenant. AbpSession.TenantId: {AbpSession.TenantId}, given tenantId: {tenantId}"); } }

For this reason, we require your support to understand what the problem is and how to solve it. Thank you

I'm using ASPNET CORE & Angular v 11.3.1

I'm having an issue impersonating in my server I have my solution runing on AWS angular is located on a S3 bucket static website and my Net Core solution is on an ElastickBeanstalk EC2 I also use a DNS with cloudflare to reach the server

The issue is that I can impersonate properly running the solution locally everything works fine but as soon as I use this on the server I always get 500 internal server error:

The trace of the error is this

Sep 14 21:03:07 ip-172-30-1-6 web: ERROR 2022-09-14 21:03:07,465 [31 ] Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:07 ip-172-30-1-6 web: System.Exception: Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:07 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.CheckCurrentTenant(Nullable1 tenantId) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 113 Sep 14 21:03:07 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.GetImpersonatedUserAndIdentity(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 42 Sep 14 21:03:07 ip-172-30-1-6 web: at PARPlatform.Web.Controllers.TokenAuthController.ImpersonatedAuthenticate(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Web.Core\Controllers\TokenAuthController.cs:line 379 Sep 14 21:03:07 ip-172-30-1-6 web: at lambda_method2674(Closure , Object ) Sep 14 21:03:07 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) Sep 14 21:03:07 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) Sep 14 21:03:07 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:07 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) Sep 14 21:03:07 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) Sep 14 21:03:07 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:07 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:09 ip-172-30-1-6 web: ERROR 2022-09-14 21:03:09,284 [31 ] Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:09 ip-172-30-1-6 web: System.Exception: Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:09 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.CheckCurrentTenant(Nullable1 tenantId) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 113 Sep 14 21:03:09 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.GetImpersonatedUserAndIdentity(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 42 Sep 14 21:03:09 ip-172-30-1-6 web: at PARPlatform.Web.Controllers.TokenAuthController.ImpersonatedAuthenticate(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Web.Core\Controllers\TokenAuthController.cs:line 379 Sep 14 21:03:09 ip-172-30-1-6 web: at lambda_method2674(Closure , Object ) Sep 14 21:03:09 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) Sep 14 21:03:09 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) Sep 14 21:03:09 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:09 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) Sep 14 21:03:09 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) Sep 14 21:03:09 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:09 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:11 ip-172-30-1-6 web: ERROR 2022-09-14 21:03:11,232 [31 ] Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:11 ip-172-30-1-6 web: System.Exception: Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:11 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.CheckCurrentTenant(Nullable1 tenantId) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 113 Sep 14 21:03:11 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.GetImpersonatedUserAndIdentity(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 42 Sep 14 21:03:11 ip-172-30-1-6 web: at PARPlatform.Web.Controllers.TokenAuthController.ImpersonatedAuthenticate(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Web.Core\Controllers\TokenAuthController.cs:line 379 Sep 14 21:03:11 ip-172-30-1-6 web: at lambda_method2674(Closure , Object ) Sep 14 21:03:11 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) Sep 14 21:03:11 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) Sep 14 21:03:11 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:11 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) Sep 14 21:03:11 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) Sep 14 21:03:11 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:11 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:13 ip-172-30-1-6 web: ERROR 2022-09-14 21:03:13,333 [26 ] Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:13 ip-172-30-1-6 web: System.Exception: Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:13 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.CheckCurrentTenant(Nullable1 tenantId) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 113 Sep 14 21:03:13 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.GetImpersonatedUserAndIdentity(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 42 Sep 14 21:03:13 ip-172-30-1-6 web: at PARPlatform.Web.Controllers.TokenAuthController.ImpersonatedAuthenticate(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Web.Core\Controllers\TokenAuthController.cs:line 379 Sep 14 21:03:13 ip-172-30-1-6 web: at lambda_method2674(Closure , Object ) Sep 14 21:03:13 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) Sep 14 21:03:13 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) Sep 14 21:03:13 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:13 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) Sep 14 21:03:13 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) Sep 14 21:03:13 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:13 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:20 ip-172-30-1-6 web: ERROR 2022-09-14 21:03:20,164 [32 ] Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:20 ip-172-30-1-6 web: System.Exception: Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 Sep 14 21:03:20 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.CheckCurrentTenant(Nullable1 tenantId) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 113 Sep 14 21:03:20 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.GetImpersonatedUserAndIdentity(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 42 Sep 14 21:03:20 ip-172-30-1-6 web: at PARPlatform.Web.Controllers.TokenAuthController.ImpersonatedAuthenticate(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Web.Core\Controllers\TokenAuthController.cs:line 379 Sep 14 21:03:20 ip-172-30-1-6 web: at lambda_method2674(Closure , Object ) Sep 14 21:03:20 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) Sep 14 21:03:20 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) Sep 14 21:03:20 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:20 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) Sep 14 21:03:20 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) Sep 14 21:03:20 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:03:20 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Sep 14 21:04:22 ip-172-30-1-6 web: WARN 2022-09-14 21:04:22,701 [27 ] Mvc.ExceptionHandling.AbpExceptionFilter - Sep 14 21:04:22 ip-172-30-1-6 web: Token de personificación es inválido o ha expirado! Sep 14 21:04:22 ip-172-30-1-6 web: Abp.UI.UserFriendlyException: Sep 14 21:04:22 ip-172-30-1-6 web: Token de personificación es inválido o ha expirado! Sep 14 21:04:22 ip-172-30-1-6 web: at PARPlatform.Authorization.Impersonation.ImpersonationManager.GetImpersonatedUserAndIdentity(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Core\Authorization\Impersonation\ImpersonationManager.cs:line 39 Sep 14 21:04:22 ip-172-30-1-6 web: at PARPlatform.Web.Controllers.TokenAuthController.ImpersonatedAuthenticate(String impersonationToken) in C:\Users\pedro\OneDrive\Documentos\plataformapar\aspnet-core\src\PARPlatform.Web.Core\Controllers\TokenAuthController.cs:line 379 Sep 14 21:04:22 ip-172-30-1-6 web: at lambda_method2674(Closure , Object ) Sep 14 21:04:22 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) Sep 14 21:04:22 ip-172-30-1-6 web: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)

Showing 1 to 2 of 2 entries