-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add Forwarded headers to the fetch request. #382
Conversation
To be cautious re: privacy/security, specify only host. Note that this changes behavior for anybody who was previously including "Forwarded" or "X-Forwarded-Host" in their ForwardedRequestHeaders in the config.
@@ -183,6 +183,8 @@ func (this *SignerSuite) TestSimple() { | |||
this.Assert().Equal(fakePath, this.lastRequest.URL.String()) | |||
this.Assert().Equal(userAgent, this.lastRequest.Header.Get("User-Agent")) | |||
this.Assert().Equal("1.1 amppkg", this.lastRequest.Header.Get("Via")) | |||
this.Assert().Equal(`host="example.com"`, this.lastRequest.Header.Get("Forwarded")) |
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.
Could you add a test that has other parameters apart from host?
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.
There are no other parameters in the prod code:
amppackager/packager/signer/signer.go
Line 184 in 47085ca
req.Header.Set("Forwarded", `host=` + quotedHost) |
I think the only thing I didn't add a test for is the concatenation if the upstream request has an XFH header:
amppackager/packager/signer/signer.go
Lines 186 to 188 in 47085ca
if oldXFH := serveHTTPReq.Header.Get("X-Forwarded-Host"); oldXFH != "" { | |
xfh = oldXFH + "," + xfh | |
} |
Is that what you want me to add a test for?
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.
You can add a test for that, too if you'd like. I was more looking at the comment:
// TODO(twifkak): Extract host from upstream Forwarded header
// and concatenate. (Do not include any other parameters, as
// they may lead to over-signing.)
If you can add a test where the over-signing doesn't happen.
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.
Ah, my mistake. Good idea. Done, PTAL.
To be cautious re: privacy/security, specify only host. Note that this
changes behavior for anybody who was previously including "Forwarded" or
"X-Forwarded-Host" in their ForwardedRequestHeaders in the config.
Fixes #260.