Skip to content
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 use Custom Response Filter or Local Reply Modification Config to modify response based on upstream service response body or using command operator such as %RESPONSE_CODE_DETAILS% in Envoy? #33414

Closed
darshak-patel opened this issue Apr 9, 2024 · 6 comments
Labels
area/custom_response question Questions that are neither investigations, bugs, nor enhancements stale stalebot believes this issue/PR has not been touched recently

Comments

@darshak-patel
Copy link

I want to modify the response return by envoy either based on upstream service response body or using command operator such as %RESPONSE_CODE_DETAILS% in envoy, but I am not able to find appropriate example for it.

In case of expired jwt, envoy returns "jwt is expired" response body from codec api, but I don't want to return the body as it is and want to modify before sending it to client. Example, 401 is very generic error code and expired token and invalid token both can have separate error message for better understanding.

@darshak-patel darshak-patel added the triage Issue requires triage label Apr 9, 2024
@RyanTheOptimist RyanTheOptimist added question Questions that are neither investigations, bugs, nor enhancements area/custom_response and removed triage Issue requires triage labels Apr 10, 2024
@RyanTheOptimist
Copy link
Contributor

CC: @yanavlasov @zuercher

@zuercher
Copy link
Member

Presuming that this is a local reply generated by Envoy's jwt_authn filter, some kinds of modifications can be made with local_reply_config. If that's not sufficient, you're left with using some other filter to inspect and modify the response. Possibilities include the lua filter, writing a custom WASM filter, or writing a custom C++ filter.

@darshak-patel
Copy link
Author

Let's say if response is generated by jwt_auth filter of envoy then it will always set status code as 401 and response body will be based on the fault name such as "Jwt is expired" or "signature is invalid" something like that. My question here is how local_reply_config can understand if the error is "jwt is expired" then go and pick this error format and if error is "invalid signature" go and pick this error message.I know one way is to write lua filter that can extract the body and check if body is this then add this header so local_reply_config filter can do check based on header and status code, but I don't want to go this way because it can add some latency. Is there any other way possible?

@darshak-patel
Copy link
Author

Anyone can help on this please?

Copy link

github-actions bot commented Jun 4, 2024

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Jun 4, 2024
Copy link

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/custom_response question Questions that are neither investigations, bugs, nor enhancements stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

3 participants