Skip to content

Commit 3b06457

Browse files
Add changelog + fmt
1 parent f4099e9 commit 3b06457

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### New Features and Improvements
66

7+
* Add option to add a timeout for browser confirmation in the U2M authentication flow.
8+
79
### Bug Fixes
810

911
* User provided scopes are now properly propagated in OAuth flows.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void setValueOnConfig(DatabricksConfig cfg, String value) throws IllegalA
4545
if (value == null || value.trim().isEmpty()) {
4646
return;
4747
}
48-
48+
4949
if (field.getType() == String.class) {
5050
field.set(cfg, value);
5151
} else if (field.getType() == int.class) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public class DatabricksConfig {
165165
private Boolean disableAsyncTokenRefresh;
166166

167167
/**
168-
* The duration to wait for a browser response during U2M authentication before timing out.
169-
* If set to 0 or null, the connector waits for an indefinite amount of time.
168+
* The duration to wait for a browser response during U2M authentication before timing out. If set
169+
* to 0 or null, the connector waits for an indefinite amount of time.
170170
*/
171171
@ConfigAttribute(env = "DATABRICKS_OAUTH_BROWSER_AUTH_TIMEOUT")
172172
private Duration oauthBrowserAuthTimeout;

databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/Consent.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
import java.io.Serializable;
1515
import java.net.*;
1616
import java.nio.charset.StandardCharsets;
17+
import java.time.Duration;
1718
import java.util.Arrays;
1819
import java.util.HashMap;
1920
import java.util.Map;
2021
import java.util.Objects;
2122
import java.util.Optional;
22-
import java.time.Duration;
23-
2423
import org.apache.commons.io.IOUtils;
2524
import org.slf4j.Logger;
2625
import org.slf4j.LoggerFactory;
@@ -402,7 +401,8 @@ public Map<String, String> getParams() {
402401
Duration t = timeout.get();
403402
lock.wait(t.toMillis());
404403
if (params == null) {
405-
throw new DatabricksException("OAuth browser authentication timed out after " + t.getSeconds() + " seconds");
404+
throw new DatabricksException(
405+
"OAuth browser authentication timed out after " + t.getSeconds() + " seconds");
406406
}
407407
} else {
408408
lock.wait();

databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/ExternalBrowserCredentialsProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.HashSet;
1010
import java.util.Objects;
1111
import java.util.Optional;
12-
import java.time.Duration;
1312
import java.util.Set;
1413
import org.slf4j.Logger;
1514
import org.slf4j.LoggerFactory;

databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/OAuthClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
import java.security.NoSuchAlgorithmException;
1111
import java.security.SecureRandom;
1212
import java.time.Duration;
13-
import java.util.Arrays;
13+
import java.util.Base64;
14+
import java.util.HashMap;
1415
import java.util.List;
1516
import java.util.Map;
1617
import java.util.Objects;
1718
import java.util.Optional;
18-
import java.util.Base64;
19-
import java.util.HashMap;
2019
import java.util.stream.Collectors;
2120

2221
/**

databricks-sdk-java/src/test/java/com/databricks/sdk/core/DatabricksConfigTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,18 @@ public void testGetTokenSourceWithOAuth() {
255255
@Test
256256
public void testOAuthBrowserAuthTimeout() {
257257
DatabricksConfig config = new DatabricksConfig();
258-
258+
259259
// Test default value (should be null)
260260
assertNull(config.getOAuthBrowserAuthTimeout());
261-
261+
262262
// Test setting the timeout using Duration
263263
config.setOAuthBrowserAuthTimeout(Duration.ofSeconds(30));
264264
assertEquals(Duration.ofSeconds(30), config.getOAuthBrowserAuthTimeout());
265-
265+
266266
// Test setting the timeout using int (backward compatibility)
267267
config.setOAuthBrowserAuthTimeout(60);
268268
assertEquals(Duration.ofSeconds(60), config.getOAuthBrowserAuthTimeout());
269-
269+
270270
// Test setting to 0 (should be null for indefinite wait)
271271
config.setOAuthBrowserAuthTimeout(0);
272272
assertNull(config.getOAuthBrowserAuthTimeout());
@@ -276,17 +276,17 @@ public void testOAuthBrowserAuthTimeout() {
276276
public void testEnvironmentVariableLoading() {
277277
// Test that environment variables are now loaded properly for Duration and Integer
278278
DatabricksConfig config = new DatabricksConfig();
279-
279+
280280
// Set environment variable
281281
Map<String, String> env = new HashMap<>();
282282
env.put("DATABRICKS_OAUTH_BROWSER_AUTH_TIMEOUT", "30");
283283
env.put("DATABRICKS_DEBUG_TRUNCATE_BYTES", "100");
284284
env.put("DATABRICKS_RATE_LIMIT", "50");
285-
285+
286286
// Resolve config with environment
287287
Environment environment = new Environment(env, new ArrayList<>(), "Linux");
288288
config.resolve(environment);
289-
289+
290290
// These should now be loaded properly
291291
assertEquals(Duration.ofSeconds(30), config.getOAuthBrowserAuthTimeout());
292292
assertEquals(Integer.valueOf(100), config.getDebugTruncateBytes());
@@ -297,15 +297,15 @@ public void testEnvironmentVariableLoading() {
297297
public void testEnvironmentVariableLoadingZeroTimeout() {
298298
// Test that environment variable with value 0 results in null Duration
299299
DatabricksConfig config = new DatabricksConfig();
300-
300+
301301
// Set environment variable to 0
302302
Map<String, String> env = new HashMap<>();
303303
env.put("DATABRICKS_OAUTH_BROWSER_AUTH_TIMEOUT", "0");
304-
304+
305305
// Resolve config with environment
306306
Environment environment = new Environment(env, new ArrayList<>(), "Linux");
307307
config.resolve(environment);
308-
308+
309309
// Should be null for indefinite wait
310310
assertNull(config.getOAuthBrowserAuthTimeout());
311311
}

databricks-sdk-java/src/test/java/com/databricks/sdk/core/oauth/ConsentTest.java

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,36 @@ public class ConsentTest {
1010

1111
@Test
1212
public void testConsentWithBrowserAuthTimeout() {
13-
Consent consent = new Consent.Builder()
14-
.withClientId("test-client-id")
15-
.withClientSecret("test-client-secret")
16-
.withAuthUrl("https://test.com/auth")
17-
.withTokenUrl("https://test.com/token")
18-
.withRedirectUrl("http://localhost:8080/callback")
19-
.withState("test-state")
20-
.withVerifier("test-verifier")
21-
.withBrowserTimeout(Duration.ofSeconds(30))
22-
.build();
13+
Consent consent =
14+
new Consent.Builder()
15+
.withClientId("test-client-id")
16+
.withClientSecret("test-client-secret")
17+
.withAuthUrl("https://test.com/auth")
18+
.withTokenUrl("https://test.com/token")
19+
.withRedirectUrl("http://localhost:8080/callback")
20+
.withState("test-state")
21+
.withVerifier("test-verifier")
22+
.withBrowserTimeout(Duration.ofSeconds(30))
23+
.build();
2324

2425
// Verify that the timeout is properly set
2526
assertEquals(Optional.of(Duration.ofSeconds(30)), consent.getBrowserTimeout());
2627
}
2728

2829
@Test
2930
public void testConsentWithoutBrowserAuthTimeout() {
30-
Consent consent = new Consent.Builder()
31-
.withClientId("test-client-id")
32-
.withClientSecret("test-client-secret")
33-
.withAuthUrl("https://test.com/auth")
34-
.withTokenUrl("https://test.com/token")
35-
.withRedirectUrl("http://localhost:8080/callback")
36-
.withState("test-state")
37-
.withVerifier("test-verifier")
38-
.build();
31+
Consent consent =
32+
new Consent.Builder()
33+
.withClientId("test-client-id")
34+
.withClientSecret("test-client-secret")
35+
.withAuthUrl("https://test.com/auth")
36+
.withTokenUrl("https://test.com/token")
37+
.withRedirectUrl("http://localhost:8080/callback")
38+
.withState("test-state")
39+
.withVerifier("test-verifier")
40+
.build();
3941

4042
// Verify that the timeout is empty when not set
4143
assertEquals(Optional.empty(), consent.getBrowserTimeout());
4244
}
43-
}
45+
}

0 commit comments

Comments
 (0)