刚开始研究Ocelot+Consul的方式,有个不明白的地方,请教下大家:
1:如果不用动态路由的方式,可以在ReRoutes中配置上游和下游路径的方式,同时可以配置授权,比如:
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 1001
}
],
"UpstreamPathTemplate": "/{everything}",
"UpstreamHttpMethod": [ "Get", "Post" ],
"LoadBalancerOptions": {
"Type": "RoundRobin"
},
"AuthenticationOptions": {
"AuthenticationProviderKey": "OcelotKey",
"AllowedScopes": []
}
}
]
其中 AuthenticationOptions是配置授权的,
但如果是使用的是ocelot+consule 使用动态路由的方式自动发现接口的方式,ReRoutes是为空,不需要配置东西的,比如:
{
"ReRoutes": [],
"Aggregates": [],
"GlobalConfiguration": {
"RequestIdKey": null,
"ServiceDiscoveryProvider": {
"Host": "localhost",
"Port": 8500,
"Type": "Consul",
"Token": null,
"ConfigurationKey": null
},
"BaseUrl": "http://localhost:81",
"LoadBalancerOptions": {
"Type": "LeastConnection",
"Key": null,
"Expiry": 0
},
"DownstreamScheme": "http"
}
}
问题:
但这样就无法配置授权了。就是无法配置AuthenticationOptions选项了。请问有会的吗?或者是不是有其他解决方案?
请指教下。豆豆不多了,请见谅。