简体   繁体   中英

forward Authorization token to routed microservices with zuul

I've been using Zuul to make an API Gateway which holds most of the SecurityConfig, and made a Jwt based Authenticaiton, however I don't know why, whenever I request one of the routes to my microservice, the Request Header, doesn't contain the Authorization even if I did zuul.myMicroservice.sensitiveHeaders=Cookie

The solution was to simply make a "pre" ZuulFilter and add a Header which contains the Authorization token

Though, you won't see that header show up in Postman, it is still there and you can intercept it in your microservice by makign a filter that inherits OncePerRequest and call this on doFilter Internal:

String authHeaderParam  = request.getHeaders(HttpHeaders.AUTHORIZATION).nextElement();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM