fix: Work around gRPC-Gateway bug in X-Forwarded-For
handling
#2152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR primarily aims to work around an issue with
X-Forwarded-For
handling in the gRPC-Gateway (grpc-ecosystem/grpc-gateway#4320).Given a remote IP of 4.4.4.4 sending incoming headers of
the resulting headers forwarded by the gRPC-gateway are
The workaround I have added means that the resulting headers are
We now join the values with
", "
rather than"|"
to preserve the de-facto standard syntax.This PR also prevents spoofing the remote address in the audit logs by setting the
x-cerbos-http-remote-addr
header; currently we take that header into account even for requests not originating from the gRPC-Gateway where it should be set. Even in the case of requests from the gRPC-Gateway, our header is appended to the request headers, so we need to make sure to use the last value for the header, not the first.