-
Notifications
You must be signed in to change notification settings - Fork 973
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
Drop standard port (443 for HTTPS, 80 for HTTP) from host header #309
Drop standard port (443 for HTTPS, 80 for HTTP) from host header #309
Conversation
The Travis failure does not appear related to the change in this PR. |
Yeah, you can ignore the Travis failure (Travis is broken atm, being worked on re: #286) :) Sooo, I'll admit that I'm a bit confused why this is necessary. Could you explain how it breaks AWS authentication? I don't think there is an provision in the HTTP spec that says you shouldn't include the port for standard schemes? I'm worried about introducing explicit edge-cases like this because the clients try hard to remain un-opinionated. For example, a user may be relying on those same header values for an upstream service, proxy, etc before it reaches the ES cluster. It would be opinionated of us to start removing headers to fix an edge-case with a service. The new 2.0 branch is basically 100% pluggable, so I think a better solution would be to write a custom I'm looking at what'd be required to inject a custom We could work on making injecting a custom |
There's a provision in RFC 3986 that URIs should omit a port when it's the default for a given scheme, but you're right that it's a "should" and not a "must." AWS authentication requires finding the SHA-256 of a canonicalized form of a request, so minor variations (like including :80 or :443 at the end of a host header) will result in an invalid signature. This might affect other digest-based authentication schemes (like Hawk), but I haven't done enough research to say that with certainty. As far as the $requestToHandle['headers']['host'][0]
= parse_url($requestToHandle['headers']['host'][0])['host']; |
That's a good point, a custom Handler would definitely be the path of least resistance in this case. Although I'd still like to improve the Re: Hawk, it appears that the port is always used. It's unclear if it's mandatory (since Hawk doesn't have a written protocol per-se, just the reference code which acts as the protocol), but in all cases that I could find they always fallback to an explicit port if not provided. E.g.:
That was a brief and very unscientific survey of the code, so I may be wrong :) After chatting with some of the other client devs, I'm inclined to keep this functionality out of core and let the end-user plug in a custom handler instead. It feels like the perfect use-case for a pluggable component (small custom logic that is opinionated). Especially since other authentication schemes may work differently, and it's a "should" not "must" requirement in the HTTP spec. |
Totally unrelated, if you have a moment to sign the Elastic CLA it'll expedite any future PRs. :) |
Including the port can complicate certain authentication schemes (such as AWS authentication) that expect only non-standard ports to be included in the host header.