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

Adding x-forwarded-host support #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kdima
Copy link
Collaborator

@kdima kdima commented Feb 11, 2019

No description provided.

Dmytro Kislov added 2 commits February 11, 2019 11:08
if !ok {
return status.Error(codes.Internal, ":authority header has not been set")
}
authority, ok := md[":authority"]
Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link

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")
Copy link
Collaborator

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.

@kdima kdima changed the title Adding x-forwarded-for support Adding x-forwarded-host support Feb 11, 2019
@@ -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)
Copy link
Collaborator

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants