personball / abplus

Abp Plus, Extension For https://github.com/aspnetboilerplate/aspnetboilerplate
MIT License
172 stars 51 forks source link

这个插件内部有权限验证模块吗? #21

Closed cunzhu closed 4 years ago

cunzhu commented 4 years ago

大神你好,我已经解决掉了所有异常,但是依然没有收到应答消息,我在Warn日志里面收到以下异常,请问这个插件内部有权限验证模块吗?当前用户已经登录系统了呀,为什么会报这个警告呢,希望能得到你的回复 WARN 2019-12-20 11:45:22,511 [ker 1] us.Retry.ErrorTracking.InMemErrorTracker - Unhandled exception 2 while handling message with ID "4cb46c5b-c35f-466f-964a-ae6a5b50875e" Abp.Authorization.AbpAuthorizationException: 当前用户没有登录到系统! at Abp.Authorization.AuthorizationHelper.AuthorizeAsync(IEnumerable1 authorizeAttributes) in D:\Github\aspnetboilerplate\src\Abp\Authorization\AuthorizationHelper.cs:line 42 at Abp.Authorization.AuthorizationHelper.CheckPermissions(MethodInfo methodInfo, Type type) in D:\Github\aspnetboilerplate\src\Abp\Authorization\AuthorizationHelper.cs:line 107 at Abp.Authorization.AuthorizationHelper.AuthorizeAsync(MethodInfo methodInfo, Type type) in D:\Github\aspnetboilerplate\src\Abp\Authorization\AuthorizationHelper.cs:line 56 at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) --- End of stack trace from previous location where exception was thrown --- at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.Run(Func1 action) at Abp.Authorization.AuthorizationInterceptor.Intercept(IInvocation invocation) in D:\Github\aspnetboilerplate\src\Abp\Authorization\AuthorizationInterceptor.cs:line 20 at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:line 78 at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Auditing.AuditingInterceptor.PerformAsyncAuditing(IInvocation invocation, AuditInfo auditInfo) in D:\Github\aspnetboilerplate\src\Abp\Auditing\AuditingInterceptor.cs:line 86 at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.IHandleMessages1Proxy.Handle(TestMessage message) at Rebus.Pipeline.Receive.HandlerInvoker1.Invoke() in C:\projects-rebus\Rebus\Rebus\Pipeline\Receive\HandlerInvoker.cs:line 154 at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func1 next) in C:\projects-rebus\Rebus\Rebus\Pipeline\Receive\DispatchIncomingMessageStep.cs:line 67 at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func1 next) in C:\projects-rebus\Rebus\Rebus\Sagas\LoadSagaDataStep.cs:line 66 at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func1 next) in C:\projects-rebus\Rebus\Rebus\Pipeline\Receive\ActivateHandlersStep.cs:line 47 at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func1 next) in C:\projects-rebus\Rebus\Rebus\Pipeline\Receive\HandleRoutingSlipsStep.cs:line 42 at Rebus.Retry.Simple.FailedMessageWrapperStep.Process(IncomingStepContext context, Func1 next) in C:\projects-rebus\Rebus\Rebus\Retry\Simple\FailedMessageWrapperStep.cs:line 42 at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func1 next) in C:\projects-rebus\Rebus\Rebus\Pipeline\Receive\DeserializeIncomingMessageStep.cs:line 34 at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func1 next) in C:\projects-rebus\Rebus\Rebus\Pipeline\Receive\HandleDeferredMessagesStep.cs:line 121 at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func1 next) in C:\projects-rebus\Rebus\Rebus\Retry\FailFast\FailFastStep.cs:line 41 at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId) in C:\projects-rebus\Rebus\Rebus\Retry\Simple\SimpleRetryStrategyStep.cs:line 120

cunzhu commented 4 years ago

当我将后台作业关闭后就没有这个错误了

cunzhu commented 4 years ago

你能写出这个插件,说明你肯定在实际的应用中使用过,能冒昧的问一下,你是怎么用的吗?

personball commented 4 years ago

消费端是单独线程在跑的,和当前web用户的登陆状态无关,请检查下消费端的代码执行过程中是否有用了标记了[AbpAuthorize] 或者 [Authorize]的类或方法

另外,消费端执行的逻辑中不可使用Session,Session底层也是依赖web认证机制的

cunzhu commented 4 years ago

问题已解决,感谢楼上的大神