abp icon indicating copy to clipboard operation
abp copied to clipboard

Bearer was not authenticated. /api/abp/permissions?providerName=User&providerKey=id

Open burningmyself opened this issue 7 years ago • 14 comments

2019-07-05 17:17:46.110 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:65115/api/abp/permissions?providerName=User&providerKey=4d1c34c3-26f8-327b-39aa-39eed3492b30  
2019-07-05 17:17:46.120 +08:00 [INF] Successfully validated the token.
2019-07-05 17:17:46.120 +08:00 [DBG] AuthenticationScheme: Bearer was successfully authenticated.
2019-07-05 17:17:46.141 +08:00 [INF] Route matched with {area = "abp", action = "GetAsync", controller = "Permissions"}. Executing action Volo.Abp.PermissionManagement.PermissionsController.GetAsync (Volo.Abp.PermissionManagement.HttpApi)
2019-07-05 17:17:46.166 +08:00 [INF] Executing action method Volo.Abp.PermissionManagement.PermissionsController.GetAsync (Volo.Abp.PermissionManagement.HttpApi) with arguments (["User","4d1c34c3-26f8-327b-39aa-39eed3492b30"]) - Validation state: "Valid"
2019-07-05 17:17:46.173 +08:00 [INF] Authorization was successful.
2019-07-05 17:17:46.236 +08:00 [DBG] AuthenticationScheme: Bearer was successfully authenticated.
2019-07-05 17:17:46.236 +08:00 [WRN] Could not find IdentityClientConfiguration for . Either define a configuration for  or set a default configuration.
2019-07-05 17:17:46.236 +08:00 [INF] Start processing HTTP request GET "http://localhost:65115/api/identity/user/4d1c34c3-26f8-327b-39aa-39eed3492b30/roles?api-version=1.0"
2019-07-05 17:17:46.237 +08:00 [INF] Sending HTTP request GET "http://localhost:65115/api/identity/user/4d1c34c3-26f8-327b-39aa-39eed3492b30/roles?api-version=1.0"
2019-07-05 17:17:46.253 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:65115/api/identity/user/4d1c34c3-26f8-327b-39aa-39eed3492b30/roles?api-version=1.0  
2019-07-05 17:17:46.253 +08:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
2019-07-05 17:17:46.253 +08:00 [DBG] requestId: 0HLO155IICJHH:00000004, previousRequestId: no previous request id, message: ocelot pipeline started
2019-07-05 17:17:46.253 +08:00 [DBG] requestId: 0HLO155IICJHH:00000004, previousRequestId: no previous request id, message: Upstream url path is /api/identity/user/4d1c34c3-26f8-327b-39aa-39eed3492b30/roles
2019-07-05 17:17:46.254 +08:00 [WRN] requestId: 0HLO155IICJHH:00000004, previousRequestId: no previous request id, message: DownstreamRouteFinderMiddleware setting pipeline errors. IDownstreamRouteFinder returned Error Code: UnableToFindDownstreamRouteError Message: Failed to match ReRoute configuration for upstream path: /api/identity/user/4d1c34c3-26f8-327b-39aa-39eed3492b30/roles, verb: GET.
2019-07-05 17:17:46.254 +08:00 [WRN] requestId: 0HLO155IICJHH:00000004, previousRequestId: no previous request id, message: Failed to match ReRoute configuration for upstream path: /api/identity/user/4d1c34c3-26f8-327b-39aa-39eed3492b30/roles, verb: GET.
2019-07-05 17:17:46.254 +08:00 [WRN] requestId: 0HLO155IICJHH:00000004, previousRequestId: no previous request id, message: Error Code: UnableToFindDownstreamRouteError Message: Failed to match ReRoute configuration for upstream path: /api/identity/user/4d1c34c3-26f8-327b-39aa-39eed3492b30/roles, verb: GET. errors found in ResponderMiddleware. Setting error response for request path:/api/identity/user/4d1c34c3-26f8-327b-39aa-39eed3492b30/roles, request method: GET
2019-07-05 17:17:46.254 +08:00 [DBG] requestId: 0HLO155IICJHH:00000004, previousRequestId: no previous request id, message: ocelot pipeline finished
2019-07-05 17:17:46.254 +08:00 [INF] Request finished in 0.7702ms 404 
2019-07-05 17:17:46.266 +08:00 [INF] Received HTTP response after 29.282600000000002ms - "NotFound"
2019-07-05 17:17:46.266 +08:00 [INF] End processing HTTP request after 29.662300000000002ms - "NotFound"
2019-07-05 17:17:47.682 +08:00 [ERR] ---------- RemoteServiceErrorInfo ----------
2019-07-05 17:17:47.682 +08:00 [ERR] {
  "code": null,
  "message": "对不起,在处理你的请求期间,产生了一个服务器内部错误!",
  "details": null,
  "validationErrors": null
}
2019-07-05 17:17:47.682 +08:00 [ERR] Remote service returns error! HttpStatusCode: NotFound, ReasonPhrase: Not Found
Volo.Abp.AbpException: Remote service returns error! HttpStatusCode: NotFound, ReasonPhrase: Not Found
   at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor`1.ThrowExceptionForResponseAsync(HttpResponseMessage response) in D:\github\abp\framework\src\Volo.Abp.Http.Client\Volo\Abp\Http\Client\DynamicProxying\DynamicHttpProxyInterceptor.cs:line 255
   at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor`1.MakeRequestAsync(IAbpMethodInvocation invocation) in D:\github\abp\framework\src\Volo.Abp.Http.Client\Volo\Abp\Http\Client\DynamicProxying\DynamicHttpProxyInterceptor.cs:line 163
   at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor`1.MakeRequestAndGetResultAsync[T](IAbpMethodInvocation invocation) in D:\github\abp\framework\src\Volo.Abp.Http.Client\Volo\Abp\Http\Client\DynamicProxying\DynamicHttpProxyInterceptor.cs:line 118
   at Volo.Abp.Castle.DynamicProxy.CastleAbpInterceptorAdapter`1.ExecuteWithReturnValueAsync[T](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Identity.HttpClientUserRoleFinder.GetRolesAsync(Guid userId) in D:\github\abp\modules\identity\src\Volo.Abp.Identity.HttpApi.Client\Volo\Abp\Identity\HttpClientUserRoleFinder.cs:line 20
   at Volo.Abp.PermissionManagement.Identity.RolePermissionManagementProvider.CheckAsync(String name, String providerName, String providerKey) in D:\github\abp\modules\identity\src\Volo.Abp.PermissionManagement.Domain.Identity\Volo\Abp\PermissionManagement\Identity\RolePermissionManagementProvider.cs:line 42
   at Volo.Abp.PermissionManagement.PermissionManager.GetInternalAsync(PermissionDefinition permission, String providerName, String providerKey) in D:\github\abp\modules\permission-management\src\Volo.Abp.PermissionManagement.Domain\Volo\Abp\PermissionManagement\PermissionManager.cs:line 118
   at Volo.Abp.PermissionManagement.PermissionManager.GetAsync(String permissionName, String providerName, String providerKey) in D:\github\abp\modules\permission-management\src\Volo.Abp.PermissionManagement.Domain\Volo\Abp\PermissionManagement\PermissionManager.cs:line 55
   at Volo.Abp.PermissionManagement.PermissionAppService.GetAsync(String providerName, String providerKey) in D:\github\abp\modules\permission-management\src\Volo.Abp.PermissionManagement.Application\Volo\Abp\PermissionManagement\PermissionAppService.cs:line 77
   at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\github\abp\framework\src\Volo.Abp.Validation\Volo\Abp\Validation\ValidationInterceptor.cs:line 43
   at Volo.Abp.Castle.DynamicProxy.CastleAbpInterceptorAdapter`1.ExecuteWithReturnValueAsync[T](IInvocation invocation, IInvocationProceedInfo proceedInfo) in D:\github\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpInterceptorAdapter.cs:line 86
   at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\github\abp\framework\src\Volo.Abp.Auditing\Volo\Abp\Auditing\AuditingInterceptor.cs:line 52
   at Volo.Abp.Castle.DynamicProxy.CastleAbpInterceptorAdapter`1.ExecuteWithReturnValueAsync[T](IInvocation invocation, IInvocationProceedInfo proceedInfo) in D:\github\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpInterceptorAdapter.cs:line 86
   at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\github\abp\framework\src\Volo.Abp.Authorization\Volo\Abp\Authorization\AuthorizationInterceptor.cs:line 39
   at Volo.Abp.Castle.DynamicProxy.CastleAbpInterceptorAdapter`1.ExecuteWithReturnValueAsync[T](IInvocation invocation, IInvocationProceedInfo proceedInfo) in D:\github\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpInterceptorAdapter.cs:line 86
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\github\abp\framework\src\Volo.Abp.Uow\Volo\Abp\Uow\UnitOfWorkInterceptor.cs:line 47
   at Volo.Abp.Castle.DynamicProxy.CastleAbpInterceptorAdapter`1.ExecuteWithReturnValueAsync[T](IInvocation invocation, IInvocationProceedInfo proceedInfo) in D:\github\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpInterceptorAdapter.cs:line 86
   at lambda_method(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
2019-07-05 17:17:47.683 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'.
2019-07-05 17:17:47.684 +08:00 [INF] Executed action Volo.Abp.PermissionManagement.PermissionsController.GetAsync (Volo.Abp.PermissionManagement.HttpApi) in 1542.8056000000001ms
2019-07-05 17:17:47.684 +08:00 [INF] Request finished in 1575.1489ms 500 application/json; charset=utf-8

burningmyself avatar Jul 05 '19 09:07 burningmyself

why Authorization was successful then what was not authenticated.

burningmyself avatar Jul 05 '19 09:07 burningmyself

2019-07-05 16:42:52.448 +08:00 [INF] Request starting HTTP/1.1 OPTIONS http://localhost:65115/api/abp/permissions?providerName=Role&providerKey=admin  
2019-07-05 16:42:52.448 +08:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
2019-07-05 16:42:52.448 +08:00 [WRN] AcceptLanguageHeaderRequestCultureProvider returned the following unsupported cultures '["zh-CN","zh"]'.
2019-07-05 16:42:52.448 +08:00 [WRN] AcceptLanguageHeaderRequestCultureProvider returned the following unsupported UI Cultures '["zh-CN","zh"]'.
2019-07-05 16:42:52.448 +08:00 [INF] CORS policy execution successful.
2019-07-05 16:42:52.448 +08:00 [INF] Request finished in 0.5448ms 204 
2019-07-05 16:42:52.457 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:65115/api/abp/permissions?providerName=Role&providerKey=admin  
2019-07-05 16:42:52.458 +08:00 [INF] Successfully validated the token.
2019-07-05 16:42:52.458 +08:00 [DBG] AuthenticationScheme: Bearer was successfully authenticated.
2019-07-05 16:42:52.458 +08:00 [INF] CORS policy execution successful.
2019-07-05 16:42:52.459 +08:00 [INF] Route matched with {area = "abp", action = "GetAsync", controller = "Permissions"}. Executing action Volo.Abp.PermissionManagement.PermissionsController.GetAsync (Volo.Abp.PermissionManagement.HttpApi)
2019-07-05 16:42:52.460 +08:00 [INF] Executing action method Volo.Abp.PermissionManagement.PermissionsController.GetAsync (Volo.Abp.PermissionManagement.HttpApi) with arguments (["Role","admin"]) - Validation state: "Valid"
2019-07-05 16:42:52.464 +08:00 [INF] Authorization was successful.
2019-07-05 16:42:52.542 +08:00 [INF] Executed action method Volo.Abp.PermissionManagement.PermissionsController.GetAsync (Volo.Abp.PermissionManagement.HttpApi), returned result Microsoft.AspNetCore.Mvc.ObjectResult in 81.7865ms.
2019-07-05 16:42:52.543 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.PermissionManagement.GetPermissionListResultDto'.
2019-07-05 16:42:52.543 +08:00 [INF] Executed action Volo.Abp.PermissionManagement.PermissionsController.GetAsync (Volo.Abp.PermissionManagement.HttpApi) in 84.5056ms
2019-07-05 16:42:52.544 +08:00 [INF] Request finished in 87.0162ms 200 application/json; charset=utf-8

burningmyself avatar Jul 05 '19 09:07 burningmyself

Same interface, different parameters, different results

burningmyself avatar Jul 05 '19 09:07 burningmyself

You should explain what you are doing. What is the version of abp you use and the steps to reproduce it?

maliming avatar Jul 05 '19 09:07 maliming

abp 0.0.18.1 use permission-management, Do access management

burningmyself avatar Jul 05 '19 09:07 burningmyself

The steps to reproduce it?

maliming avatar Jul 05 '19 09:07 maliming

First, you need to do a "IdentityServer", then a gateway, the gateway "AbpPermissionManagementHttpApiModule reference module", and then obtain token call /api/abp/permission(" User ", "Id"), Will repeat

burningmyself avatar Jul 05 '19 09:07 burningmyself

I don't quite understand what you said "gateway" Can you elaborate on the steps to reproduce the problem? Make sure we can reproduce your problem.

maliming avatar Jul 09 '19 01:07 maliming

This gateway is the background, when I quote "AbpPermissionManagementHttpApiModule" module, configuration User permissions, reported the error, which is call/API/abp/permission (" User ", "Id") the API

burningmyself avatar Jul 09 '19 01:07 burningmyself

这是后台网关,当我引用“AbpPermissionManagementHttpApiModule”模块,配置用户权限时,报这个错误,也就是调用/api/abp/permission(" User ", "Id")这个api

burningmyself avatar Jul 09 '19 01:07 burningmyself

这是后台网关,当我引用“AbpPermissionManagementHttpApiModule”模块,配置用户权限时,报这个错误,也就是调用/ api / abp / permission(“用户”,“Id”)这个api

请问你解决了没有 我现在也遇到类似的问题,远程代理调用权限模板api 也提示未授权

thk-liu avatar Aug 20 '19 10:08 thk-liu

@thk-liu @maliming I encounted the same problem,and I solved it! change the following code app.MapWhen( ctx => ctx.Request.Path.ToString().StartsWith("/api/abp/") || ctx.Request.Path.ToString().StartsWith("/Abp/") , app2 => { app2.UseRouting(); app2.UseConfiguredEndpoints(); } ); to app.MapWhen( ctx => ctx.Request.Path.ToString().StartsWith("/api/abp/") || ctx.Request.Path.ToString().StartsWith("/Abp/") || ctx.Request.Path.ToString().StartsWith("/api/permission-management/")|| ctx.Request.Path.ToString().StartsWith("/api/feature-management/"), app2 => { app2.UseRouting(); app2.UseConfiguredEndpoints(); } ); reference https://github.com/abpframework/abp-samples/blob/master/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs

yuchengit avatar Jan 07 '21 02:01 yuchengit

Yes see https://github.com/abpframework/abp-samples/commit/cb998d2d3512f48574c3d832e7eaf1d2cfb11986

maliming avatar Jan 07 '21 02:01 maliming

我在 IdentityService.Host 引用了项目 AuthServer.Host,这样启动 IdentityService.Host 调试时就会报这个错误AuthenticationScheme: Bearer was not authenticated.。去掉 AuthServer.Host 的引用即可。

afresh avatar Mar 08 '21 00:03 afresh