0条评论
还没有人评论过~
最近在看腾飞大佬的asp.net core 微服务实战遇到了ocelot集成identity server4认证时一直给报错:
warn: Ocelot.Authentication.Middleware.AuthenticationMiddleware[0]
requestId: 0HM2ME7808IH4:00000009, previousRequestId: no previous request id, message: Client has NOT been authenticated for /user and pipeline error set. Request for authenticated route /user by was unauthenticated
warn: Ocelot.Responder.Middleware.ResponderMiddleware[0]
requestId: 0HM2ME7808IH4:00000009, previousRequestId: no previous request id, message: Error Code: UnauthenticatedError Message: Request for authenticated route /user by was unauthenticated errors found in ResponderMiddleware. Setting error response for request path:/user, request method: GET
一直不知道问题出来哪里,小弟请求园子里各位大佬给指点一下
【Gateway.API】中Ocelot.json配置如下:
{
"Routes": [
{
"DownstreamPathTemplate": "/api/user",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5001
}
],
"UpstreamPathTemplate": "/user",
"UpstreamHttpMethod": [ "Get" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "finbook",
"AllowedScopes": []
}
}
],
"GlobalConfiguration": {
"BaseUrl": "http://localhost:5000"
}
}
【Gateway.API】中Startup.cs配置如下:
PostMan 请求:
identityServer4 最新版本的 需要配置APISCOPE,老版本 只需要配置APIResource即可。不知道你有没有配。
详细可见 is4 文档 Resource章节
在ASP.NET Core中使用Ocelot
https://www.52interview.com/book/20