Spring Cloud系列之客戶端請求帶「Authorization」請求頭,通過zuul轉發後丟失了

先擺解決方案cookie

方法一:app

方法二:ui

zuul.routes.<routeName>.sensitive-headers=
zuul.routes.<routeName>.custom-sensitive-headers=true

 

緣由:Zuul進行路由轉發時RibbonRoutingFilter過濾器,對請求參數和請求頭進行了從新過濾和組裝spa

RibbonRoutingFilter代碼:debug

本次咱們主要關注buildZuulRequestHeaders這個方法3d

裏面有個isIncludedHeader(name)code

debug調式以下:server

發現默認過濾掉的請求頭有:authorization、set-cookie、cookie、host、connection、content-length、content-encoding、server、transfer-encoding、x-application-contextblog

至於:這一部分是在zuulProperties這個全局屬性類中設置的路由

因此,咱們在回到開頭部分的解決方案一中就是將默認的sensitiveHeaders清空

 

相關文章
相關標籤/搜索