Skip to content

Commit dd6ee4e

Browse files
Fix formatting and add changelog entry
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2a1667e commit dd6ee4e

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New Features and Improvements
66

77
### Bug Fixes
8+
* Fixed Databricks CLI authentication to detect when the cached token's scopes don't match the SDK's configured scopes. Previously, a scope mismatch was silently ignored, causing requests to use wrong permissions. The SDK now raises an error with instructions to re-authenticate.
89

910
### Security Vulnerabilities
1011

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.databricks.sdk.core.oauth.Token;
66
import com.databricks.sdk.core.utils.OSUtils;
77
import com.databricks.sdk.support.InternalApi;
8-
import com.fasterxml.jackson.databind.JsonNode;
98
import com.fasterxml.jackson.databind.ObjectMapper;
109
import java.nio.charset.StandardCharsets;
1110
import java.util.*;
@@ -200,8 +199,7 @@ private static Map<String, Object> getJwtClaims(String accessToken) {
200199
try {
201200
String[] parts = accessToken.split("\\.");
202201
if (parts.length != 3) {
203-
LOG.debug(
204-
"Tried to decode access token as JWT, but failed: {} components", parts.length);
202+
LOG.debug("Tried to decode access token as JWT, but failed: {} components", parts.length);
205203
return null;
206204
}
207205
byte[] payloadBytes = Base64.getUrlDecoder().decode(parts[1]);

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ private static String makeJwt(Map<String, Object> claims) {
2525
.withoutPadding()
2626
.encodeToString("{\"alg\":\"none\"}".getBytes(StandardCharsets.UTF_8));
2727
String payload =
28-
Base64.getUrlEncoder()
29-
.withoutPadding()
30-
.encodeToString(MAPPER.writeValueAsBytes(claims));
28+
Base64.getUrlEncoder().withoutPadding().encodeToString(MAPPER.writeValueAsBytes(claims));
3129
return header + "." + payload + ".sig";
3230
} catch (Exception e) {
3331
throw new RuntimeException(e);
@@ -89,13 +87,11 @@ void testScopeValidation(
8987
assertThrows(
9088
DatabricksException.class,
9189
() ->
92-
DatabricksCliCredentialsProvider.validateTokenScopes(
93-
token, configuredScopes, HOST));
90+
DatabricksCliCredentialsProvider.validateTokenScopes(token, configuredScopes, HOST));
9491
} else {
9592
assertDoesNotThrow(
9693
() ->
97-
DatabricksCliCredentialsProvider.validateTokenScopes(
98-
token, configuredScopes, HOST));
94+
DatabricksCliCredentialsProvider.validateTokenScopes(token, configuredScopes, HOST));
9995
}
10096
}
10197

0 commit comments

Comments
 (0)