-
Notifications
You must be signed in to change notification settings - Fork 216
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
Adding x-forwarded-host support #39
base: master
Are you sure you want to change the base?
Conversation
if !ok { | ||
return status.Error(codes.Internal, ":authority header has not been set") | ||
} | ||
authority, ok := md[":authority"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any way of connecting these keys back to the upstream definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems incorrect. x-forwarded-for
is the list of peers forwarding the request. the authority is the intended destination of the request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks strange to me as well - I'm not clear on how x-forwarded-host
and authority
are related.
If you want to record the caller, then x-forwarded-for
seems like a good choice. X-forwarded-for is implemented in my fork: https://github.com/vgough/grpc-proxy/blob/master/proxy/handler.go
// TODO(mwitkow): Add a `forwarded` header to metadata, https://en.wikipedia.org/wiki/X-Forwarded-For. | ||
md, ok := metadata.FromIncomingContext(clientCtx) | ||
if !ok { | ||
return status.Error(codes.Internal, ":authority header has not been set") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this now an error? seems like a breaking change.
@@ -70,7 +72,18 @@ func (s *handler) handler(srv interface{}, serverStream grpc.ServerStream) error | |||
} | |||
|
|||
clientCtx, clientCancel := context.WithCancel(outgoingCtx) | |||
// TODO(mwitkow): Add a `forwarded` header to metadata, https://en.wikipedia.org/wiki/X-Forwarded-For. | |||
md, ok := metadata.FromIncomingContext(clientCtx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract to function, link to relevant docs (i.e. wikipedia)
No description provided.