我在我们的应用中使用了spring cloud gateway。我们需要从所有配置的路由中删除所有敏感报头。我已经将其配置如下-
spring:
cloud:
gateway:
default-filters:
#Remove All the sensitive request headers (Cookie, Set-Cookie & Authorization) while passing request to downstream services
- RemoveRequestHeader=Cookie
- RemoveRequestHeader=Set-Cookie
- RemoveRequestHeader=Authorization这和预期的一样工作。现在我们只需要将Authorization报头传递给其中一个路由。有没有办法对此进行配置,使我不必在所有路由中添加3个RemoveRequestHeader?
我曾尝试专门为一个路由添加Authorization请求标头,但由于路由排序的原因,它不起作用。一旦请求标头被移除,就不能再重新添加。
附注:在迁移到spring cloud gateway之前,我们使用的是Zuul &这样做是可能的。
发布于 2021-01-13 01:05:21
默认筛选器为all或nothing。要执行您想要的操作,您需要将RemoveRequestHeader添加到需要它的每个路由中,在不需要它的路由中省略它。
https://stackoverflow.com/questions/65684193
复制相似问题