-
Notifications
You must be signed in to change notification settings - Fork 566
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 requested URI discovery support #6030
Merged
Merged
Conversation
This file contains 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
oracle-contributor-agreement
bot
added
the
OCA Verified
All contributors have signed the Oracle Contributor Agreement.
label
Jan 31, 2023
tjquinno
force-pushed
the
forwarded-main
branch
from
February 3, 2023 16:22
210e0bc
to
471d8d4
Compare
tomas-langer
previously requested changes
Feb 7, 2023
.../configurable/src/main/java/io/helidon/common/configurable/RequestedUriDiscoveryContext.java
Outdated
Show resolved
Hide resolved
.../configurable/src/main/java/io/helidon/common/configurable/RequestedUriDiscoveryContext.java
Outdated
Show resolved
Hide resolved
common/http/src/main/java/io/helidon/common/http/Forwarded.java
Outdated
Show resolved
Hide resolved
common/socket/src/main/java/io/helidon/common/socket/PlainSocket.java
Outdated
Show resolved
Hide resolved
common/socket/src/main/java/io/helidon/common/socket/PlainSocket.java
Outdated
Show resolved
Hide resolved
common/socket/src/main/java/io/helidon/common/socket/SocketContext.java
Outdated
Show resolved
Hide resolved
danielkec
requested changes
Feb 9, 2023
...ive/webserver/webserver/src/main/java/io/helidon/reactive/webserver/ServerConfiguration.java
Outdated
Show resolved
Hide resolved
reactive/webserver/webserver/src/main/java/io/helidon/reactive/webserver/WebServer.java
Outdated
Show resolved
Hide resolved
...ive/webserver/webserver/src/main/java/io/helidon/reactive/webserver/SocketConfiguration.java
Outdated
Show resolved
Hide resolved
common/http/src/test/java/io/helidon/common/http/ForwardedTest.java
Outdated
Show resolved
Hide resolved
common/http/src/main/java/io/helidon/common/http/RequestedUriDiscovery.java
Outdated
Show resolved
Hide resolved
common/http/src/main/java/io/helidon/common/http/RequestedUriDiscovery.java
Outdated
Show resolved
Hide resolved
tjquinno
force-pushed
the
forwarded-main
branch
from
February 23, 2023 14:31
471d8d4
to
0b4dc84
Compare
danielkec
reviewed
Feb 23, 2023
...ive/webserver/webserver/src/main/java/io/helidon/reactive/webserver/SocketConfiguration.java
Outdated
Show resolved
Hide resolved
…to Supplier<RequestedUriDiscoveryContext> instead of its builder
danielkec
approved these changes
Feb 27, 2023
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.
Resolves #5826
Intro
Forwarded
andX-Forwarded-*
header support allows code that processes requests to obtain, to the best of Helidon's ability, the URI information as specified by the original client even if the request passed through proxies from the original client to the Helidon service.The feature adds two main outward interfaces to Helidon:
Developers or deployers can control various settings on each socket which govern the behavior of this feature:
AllowList
)Forwarded
vs.X-Forwarded-*
vs.Host
headers.In 4.x, the
RequestedUriDiscoveryContext
interface embodies these settings (inhelidon-common-configurable
along with its implementation), assignable via config or builders.The
ServerRequest
interfaces (one in Níma, one in reactive) now declare theUriInfo uriInfo()
method so developer or Helidon code working with requests can obtain the requested URI information as specified by the original client.The logic for building this new
UriInfo
record is in the new utility methodRequestedUriDiscovery.uriInfo
(inhelidon-common-http
).This method accepts neutral (not specific to either Níma or reactive) information about the request and an instance of the new
RequestedUriDiscoveryContext
interface.Because
RequestedUriDiscoveryContext
is an attribute of each socket, the server request implementation classes need a way to get the relevant socket information.In Níma
The key
ServerRequest
implementations areHttp1ServerRequest
(helidon-nima-webserver
) andHttp2ServerRequest
(helidon-nima-http2-webserver
). Both already have a reference toConnectionContext
(helidon-nima-webserver
).The
ConnectionContext
interface extends interfaceSocketContext
(inhelidon-common-socket
although it is used only by Níma, not reactive) to reflect the socket settings.Adding
RequestedUriDiscoveryContext requestedUriDiscoveryContext()
toSocketContext
(and its impls) therefore makes the discovery context available to the server request implementations.SocketContext
is also implemented by thePlainSocket
class (which the classTlsSocket
extends) andDirectSocket
,so these impls of
SocketContext
need to implementrequestedUriDiscoveryContext()
:ConnectionContextImpl
PlainSocket
DirectSocket
(inhelidon-nima-testing-junit5-webserver
)which means their constructors/factory methods/builders need to change as do the callers of those constructors/factory methods/builders:
PlainSocket#server
(invokesPlainSocket#<init>
ServerListener
(invokesPlainSocket#server
andTlsSocket#server
)In reactive
The key
ServerRequest
impl is the abstract classRequest
(helidon-reactive-webserver
).That class already has a reference to
BareRequest
to which this PR adds a getter for itsSocketConfiguration
(interface inhelidon-reactive-webserver
).The constructor for
BareRequestImpl
now accepts and stores theSocketConfiguration
which the added getter method returns.FoprwardingHandler
(helidon-reactive-webserver
) already has a reference to theSocketConfiguration
so now it passes that as an additional parameter when it invokes theBareRequestImpl
constructor.This PR also changes
SocketConfiguration
:RequestedUriDiscoveryContext requestedUriDiscoveryContext()
SocketConfigurationBuilder
:RequestedUriDiscoveryContext.Builder
config
to handle discovery contextAlso, the PR updates the impls of
SocketConfiguration
andSocketConfigurationBuilder
accordingly.Other
There are some other changes to unrelated test classes, adding new required methods.
Depends on #6109