jbonofre commented on code in PR #1538:
URL: https://github.com/apache/arrow-java/pull/1538#discussion_r4757497248


##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightConnection.java:
##########
@@ -148,6 +148,7 @@ private static ArrowFlightSqlClientHandler 
createNewClientHandler(
         .withConnectTimeout(config.getConnectTimeout())
         .withDriverVersion(driverVersion)
         .withOAuthConfiguration(config.getOauthConfiguration())
+        .withProxyDetector(config.getProxyDetector())

Review Comment:
   The proxy detector is only installed on the gRPC channel. OAuth token 
requests don't go through it: `AbstractOAuthTokenProvider.fetchNewToken` sends 
them with `request.toHTTPRequest().send()`, which uses `HttpURLConnection` and 
therefore the JVM-wide `ProxySelector`.
   
   Take 
`useProxy=true&proxyHost=proxy.example.com&proxyPort=3128&oauth.flow=client_credentials&oauth.tokenUri=https://idp.example.com/token`
 on a network where only the proxy can reach the Internet. The Flight 
connection goes through the proxy, but the token request tries to connect 
directly and fails with "Failed to send OAuth token request". The reverse also 
happens: with `nonProxyHosts=*`, token requests still go through a 
JVM-configured proxy.
   
   Could the token request use the same settings? Nimbus `HTTPRequest` has 
`setProxy(java.net.Proxy)`, so the token provider could build a `Proxy` from 
`proxyHost`/`proxyPort`, skipping it when the token endpoint matches 
`nonProxyHosts`. Proxy authentication is the tricky part: `HttpURLConnection` 
gets proxy credentials from an `Authenticator`, and the JDK disables Basic auth 
for HTTPS tunneling by default (`jdk.http.auth.tunneling.disabledSchemes`).
   
   If you would rather leave this for a follow-up, please say in the docs that 
OAuth token requests still use the JVM proxy settings, and open an issue for it.



##########
docs/source/flight_sql_jdbc_driver.rst:
##########
@@ -220,6 +220,60 @@ session setup. On expiration, the driver cancels pending 
login RPCs and throws
 ``connectTimeoutMs`` property separately controls the Netty socket connection
 timeout.
 
+Connecting Through a Proxy
+==========================
+
+By default, the driver uses the JVM proxy settings, such as the
+``https.proxyHost`` and ``https.proxyPort`` system properties. A proxy
+can instead be configured per connection with the following properties.
+They are only used when ``useProxy`` is enabled, in which case they
+take precedence over the JVM proxy settings.

Review Comment:
   OAuth token requests don't follow this yet. They still use the JVM proxy 
settings (see my comment on `ArrowFlightConnection`). The same applies to "To 
ignore the JVM proxy settings and connect directly" below. If token requests 
stay out of scope for this PR, please mention that limitation here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to