动态重新路由可以同时使用ocelot和领事服务发现和授权吗?

时间:2019-05-08 11:22:46

标签: dynamic consul service-discovery reroute ocelot

当前状态

我正在使用Ocelot块开发Api网关,并且为了进行服务发现,我正在使用Consul块。

我需要描述为here的动态路由。

问题发生的地方

一切正常,直到我想按照此page中的说明使用自己的身份服务器实施身份验证。

问题

对于使用Consul服务发现的动态重新路由,我必须具有空的重新路由

{
    "ReRoutes": []
}

对于身份验证,我需要添加以下部分到我的ReRoutes集合中

        "AuthenticationOptions": {
            "AuthenticationProviderKey": "TestKey",
            "AllowedScopes": []
        }

因此,重新路由必须更改为此:

"ReRoutes": [{
        "DownstreamHostAndPorts": [
            {
                "Host": "localhost",
                "Port": 51876,
            }
        ],
        "DownstreamPathTemplate": "/",
        "UpstreamPathTemplate": "/",
        "UpstreamHttpMethod": ["Post"],
        "ReRouteIsCaseSensitive": false,
        "DownstreamScheme": "http",
        "AuthenticationOptions": {
            "AuthenticationProviderKey": "TestKey",
            "AllowedScopes": []
        }
    }]

现在我失去了最初使用的动态路由。

有没有办法解决这个问题?

0 个答案:

没有答案