問題描述
微服務中使用 OAuth2 鑒權,直接訪問正常,通過 Zuul 訪問報錯:
{
"error": "unauthorized",
"error_description": "Full authentication is required to access this resource"
}
解決方法
在 Zuul 中添加配置:
zuul:
sensitive-headers: Cookie,Set-Cookie
原因分析
zuul.sensitive-headers (默認值 Cookie,Set-Cookie,Authorization) 是指 http header 中的敏感信息,默認情況下,ZUUL 是不轉發的
OAuth2 的鑒權信息是放在 Authorization 中,所以需要從配置中移除