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

Fixes #10160 - Verify PROXY_AUTHENTICATION is sent to forward proxies #10162

Merged

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Jul 27, 2023

Now TunnelRequest.getURI() does not return null, so normalizeRequest() can properly apply the authentication headers.

Now TunnelRequest.getURI() does not return null, so normalizeRequest() can properly apply the authentication headers.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet requested review from gregw and lorban July 27, 2023 10:34
@sbordet sbordet linked an issue Jul 27, 2023 that may be closed by this pull request
@lorban
Copy link
Contributor

lorban commented Jul 27, 2023

All tests in ForwardProxyTLSServerTest fail with HTTP 500.

sbordet added 3 commits July 28, 2023 12:59
… copied.

* Fixed restore of destination in HttpProxy.HttpProxyClientConnectionFactory.newProxyConnection(): now doing it in the promise rather than in finally block.
* Using the proxy destination (not the server's) to send subsequent CONNECT requests in case the first is not replied with 200.

Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
@sbordet
Copy link
Contributor Author

sbordet commented Jul 28, 2023

@lorban should be fixed now.

Copy link
Contributor

@lorban lorban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found one questionable change.


private boolean isHTTP2(String protocol)
{
return "h2".equalsIgnoreCase(protocol) || "h2c".equalsIgnoreCase(protocol);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this implementation, if serverOrigin only supports h2c and HttpProxy only supports h2 there will be a match. Is that expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's expected.

The reason is that if server and proxy speak the same protocol, there is no need to wrap the server protocol into a CONNECT.
h2 is just h2c over TLS, so the protocol is the same.

@sbordet sbordet requested a review from lorban July 31, 2023 15:14
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just comment a small niggle rather than a review. Happy for it to be as-is, or with niggle fixed.

Comment on lines +209 to +211
Request newRequest = client.copyRequest(request, request.getURI());
if (HttpMethod.CONNECT.is(newRequest.getMethod()))
newRequest.path(request.getPath());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a slight preference for something like

Suggested change
Request newRequest = client.copyRequest(request, request.getURI());
if (HttpMethod.CONNECT.is(newRequest.getMethod()))
newRequest.path(request.getPath());
Request newRequest = (HttpMethod.CONNECT.is(request.getMethod()))
? client.copyRequest(request, request.getPath());
: client.copyRequest(request, request.getURI());

Or if the right copyRequest semantic can't be easily provided, then at least below would be a little clearer to me:

Suggested change
Request newRequest = client.copyRequest(request, request.getURI());
if (HttpMethod.CONNECT.is(newRequest.getMethod()))
newRequest.path(request.getPath());
Request newRequest = client.copyRequest(request, request.getURI());
if (HttpMethod.CONNECT.is(request.getMethod()))
newRequest.path(request.getPath());

Copy link
Contributor Author

@sbordet sbordet Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first proposed change is not correct.

The second proposed change just replaces the variable newRequest with request, which I don't see how it is clearer? The method is not changed by copying the request.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbordet the first proposal is pseudo code: check the method of the original request first and then build the new request appropriately.

The second proposal is clearer to me, as I don't have to do the double take of thinking: oh it is conditional on its own method... oh what is its method, oh it copied it from the original request, ah so it is just the method of the original request. It is clearer just to make it conditional on the method of the original request.

@sbordet sbordet merged commit b2477d1 into jetty-10.0.x Jul 31, 2023
@sbordet sbordet deleted the fix/jetty-10-10160-tunnel-request-proxy-authentication branch July 31, 2023 16:39
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.

Verify PROXY_AUTHENTICATION is sent to forward proxies
3 participants