-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to modify authorization header of a request before forwarding to microservice from gateway. #1392
Comments
Are you trying to do this using Zuul? |
Yes, trying to do it using zuul. |
Where are you trying to use |
I have written a ZuulFilter to pass on the oauth2 token to auth service check_token endpoint for validation, and on successful validation generate a JWT at auth service which contains the permission details for the user/microservice and returns that back to ZuulFilter in the gateway. Now, I need to set this jwt in the Authentication header as a Bearer token . Below is the Filter code I have written. import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; import com.netflix.zuul.ZuulFilter; public class AuthorizationFilter extends ZuulFilter {
} Now , when the request is passed to the actual microservice I see the bearer token in the x-forwarded-prefix header in the following manner: "Bearer token/content" where content is the request path for the microservice but not able to set it in the Authorization header. |
Instead of using a request wrapper use |
zuul: |
Hello grovermanas, |
In my application, I am enabling security using authentication server. Once oauth2 token is validated , I generate a jwt token which is sent back to Gateway by Auth server. Now , before forwarding the actual request to respective microservice , I need to add this jwt token in as authorization bearer token to my original request . I tried using HttpServletRequestWrapper by overriding the getHeader(String) method but get null whenever I do getHeader() in the microservice. Looking for a way to achieve this.
The text was updated successfully, but these errors were encountered: