Merged
Conversation
Some minor cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
Certain request metadata, such as the scheme or if the request is secure are not currently available off the
HTTP::Request. See crystal-lang/crystal#5784, crystal-lang/crystal#7096, and crystal-lang/crystal#10246 for more details.It is a common practice to host a web application behind a load balancer or reverse proxy. This by itself is not a problem for Athena. However it does allow a way for that extra metadata to be exposed. However, even if it was directly, they would lose the correct values since they'd be based on the reverse proxy/load balance and not the client's original request.
This PR introduces some additional
ATH::Requestmethods to expose this extra metadata, as well as a means of handling theforwardedand/orx-forwarded-*headers that the proxy would forward to Athena. These will be used to ensure generated URLs in HTTP contexts are generated correctly, taking the proxy servers into account.This feature is opt-in, and requires the IP addresses/ranges of the proxies that should be trusted to be configured explicitly.
Changelog
.unquote,.split, and.combinemethods toATH::HeaderUtilsATH::IPUtils#host,#port,#scheme,#secure?, and#from_trusted_proxy?toATH::Request