首页 新闻 会员 周边

关于Ocelot+Consul服务发现,配置授权问题

0
悬赏园豆:15 [已关闭问题] 关闭于 2022-07-10 14:23

刚开始研究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选项了。请问有会的吗?或者是不是有其他解决方案?
请指教下。豆豆不多了,请见谅。

糯米粥的主页 糯米粥 | 初学一级 | 园豆:22
提问于:2019-09-17 22:27
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册