Skip to content

Commit 99223be

Browse files
[PECO-1598] Add README for proxy and minor fix (#273)
## Changes <!-- Summary of your changes that are easy to understand --> Added README details for proxy conf and made auth type basic when using system properties ## Tests <!-- How is this tested? --> Non functional change
1 parent b06c626 commit 99223be

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The Databricks SDK for Java includes functionality to accelerate development wit
1616
- [Single-sign-on with OAuth](#single-sign-on-sso-with-oauth)
1717
- [Error handling](#error-handling)
1818
- [Logging](#logging)
19+
- [Proxy](#proxy)
1920
- [Interface stability](#interface-stability)
2021
- [Disclaimer](#disclaimer)
2122

@@ -410,5 +411,18 @@ This will enable logging at the debug level and above. Developers can adjust the
410411

411412
Overall, the logging capabilities provided by the Databricks SDK for Java can be a powerful tool for monitoring and troubleshooting your Databricks Java projects. Developers can use the various logging methods and configuration options provided by the SDK to customize the logging output to their specific needs.
412413

414+
## Proxy
415+
Databricks SDK for Java supports clients using proxy. Clients can use their proxy setup either by providing the proxy settings in the `DatabricksConfig` configuration object or by creating a `ProxyConfig` object and passing it to the constructor of `CommonsHttpClient`. The following properties can be set in the `.databrickscfg` file to configure the proxy settings:
416+
417+
| DatabricksConfig Attribute | Description | Environment variable |
418+
|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
419+
| `use_system_properties_http` | _(Boolean)_ Setting this boolean to `true` will cause the http client to automatically use proxy settings set at the system level. Namely under `http/https.proxyHost` etc. | `USE_SYSTEM_PROPERTIES_HTTP` |
420+
| `proxy_host` | _(String)_ The proxy server host | `PROXY_HOST` |
421+
| `proxy_port` | _(Integer)_ The proxy server port | `PROXY_PORT` |
422+
| `proxy_auth_type` | _(Enum: ProxyAuthType)_ This specifies how the client authenticates with the proxy server. Currently, supported auth mechanisms are `BASIC` and `SPNEGO` (only kerberos) | `PROXY_AUTH_TYPE` |
423+
| `proxy_username` | _(String)_ The proxy user to authenticate with, when using `BASIC` auth mechanism | `PROXY_USERNAME` |
424+
| `proxy_password` | _(String)_ The proxy password to authenticate with, when using `BASIC` auth mechanism | `PROXY_PASSWORD` |
425+
426+
Note: when using Kerberos authentication in SPNEGO, the `java.security.krb5.conf` system property must point to the `krb5.conf/krb5.ini` file that contains the Kerberos configuration.
413427
## Disclaimer
414428
Databricks is actively working on stabilizing the Databricks SDK for Java's interfaces. API clients for all services are generated from specification files that are synchronized from the main platform. You are highly encouraged to pin the exact dependency version and read the [changelog](https://github.com/databricks/databricks-sdk-java/blob/main/CHANGELOG.md) where Databricks documents the changes. Databricks may have minor [documented](https://github.com/databricks/databricks-sdk-java/blob/main/CHANGELOG.md) backward-incompatible changes, such as renaming the methods or some type names to bring more consistency.

databricks-sdk-java/src/main/java/com/databricks/sdk/core/ProxyConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public enum ProxyAuthType {
1616
SPNEGO
1717
}
1818

19+
public ProxyConfig() {}
20+
1921
public ProxyConfig(DatabricksConfig config) {
2022
this.host = config.getProxyHost();
2123
this.port = config.getProxyPort();

databricks-sdk-java/src/main/java/com/databricks/sdk/core/utils/ProxyUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,26 @@ public static void setupProxy(ProxyConfig config, HttpClientBuilder builder) {
3333
Integer proxyPort = null;
3434
String proxyUser = null;
3535
String proxyPassword = null;
36+
ProxyConfig.ProxyAuthType proxyAuthType = null;
3637
if (config.getUseSystemProperties() != null && config.getUseSystemProperties()) {
3738
builder.useSystemProperties();
3839
String protocol = System.getProperty("https.proxyHost") != null ? "https" : "http";
3940
proxyHost = System.getProperty(protocol + ".proxyHost");
4041
proxyPort = Integer.parseInt(System.getProperty(protocol + ".proxyPort"));
4142
proxyUser = System.getProperty(protocol + ".proxyUser");
4243
proxyPassword = System.getProperty(protocol + ".proxyPassword");
44+
proxyAuthType = ProxyConfig.ProxyAuthType.BASIC;
4345
}
4446
// Override system properties if proxy configuration is explicitly set
4547
if (config.getHost() != null) {
4648
proxyHost = config.getHost();
4749
proxyPort = config.getPort();
4850
proxyUser = config.getUsername();
4951
proxyPassword = config.getPassword();
52+
proxyAuthType = config.getProxyAuthType();
5053
builder.setProxy(new HttpHost(proxyHost, proxyPort));
5154
}
52-
setupProxyAuth(
53-
proxyHost, proxyPort, config.getProxyAuthType(), proxyUser, proxyPassword, builder);
55+
setupProxyAuth(proxyHost, proxyPort, proxyAuthType, proxyUser, proxyPassword, builder);
5456
}
5557

5658
/**

0 commit comments

Comments
 (0)