Skip to content

Commit 891a900

Browse files
SNOW-1825482: PAT, Native OAuth & Secure Token Cache support (#1978)
1 parent dcb60b2 commit 891a900

File tree

77 files changed

+4804
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4804
-469
lines changed

FIPS/scripts/check_content.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -o pipefail
66

77
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
88

9-
if jar tvf $DIR/../target/snowflake-jdbc-fips.jar | awk '{print $8}' | grep -v -E "/$" | grep -v -E "^(net|com)/snowflake" | grep -v -E "(com|net)/\$" | grep -v -E "^META-INF" | grep -v -E "^mozilla" | grep -v -E "^com/sun/jna" | grep -v com/sun/ | grep -v mime.types | grep -v -E "^com/github/luben/zstd/" | grep -v -E "^aix/" | grep -v -E "^darwin/" | grep -v -E "^freebsd/" | grep -v -E "^linux/" | grep -v -E "^win/"; then
9+
if jar tvf $DIR/../target/snowflake-jdbc-fips.jar | awk '{print $8}' | grep -v -E "/$" | grep -v -E "^(net|com)/snowflake" | grep -v -E "(com|net)/\$" | grep -v -E "^META-INF" | grep -v -E "^iso3166_" | grep -v -E "^mozilla" | grep -v -E "^com/sun/jna" | grep -v com/sun/ | grep -v mime.types | grep -v -E "^com/github/luben/zstd/" | grep -v -E "^aix/" | grep -v -E "^darwin/" | grep -v -E "^freebsd/" | grep -v -E "^linux/" | grep -v -E "^win/"; then
1010
echo "[ERROR] JDBC jar includes class not under the snowflake namespace"
1111
exit 1
1212
fi

ci/container/test_authentication.sh

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ MVNW_EXE=$SOURCE_ROOT/mvnw
99
AUTH_PARAMETER_FILE=./.github/workflows/parameters_aws_auth_tests.json
1010
eval $(jq -r '.authtestparams | to_entries | map("export \(.key)=\(.value|tostring)")|.[]' $AUTH_PARAMETER_FILE)
1111

12+
export SF_ENABLE_EXPERIMENTAL_AUTHENTICATION=true
13+
1214
$MVNW_EXE -DjenkinsIT \
1315
-Djava.io.tmpdir=$WORKSPACE \
1416
-Djacoco.skip.instrument=true \

ci/container/test_component.sh

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ cd $SOURCE_ROOT
7676
# Avoid connection timeout on plugin dependency fetch or fail-fast when dependency cannot be fetched
7777
$MVNW_EXE --batch-mode --show-version dependency:go-offline
7878

79+
export SF_ENABLE_EXPERIMENTAL_AUTHENTICATION=true
80+
7981
if [[ "$is_old_driver" == "true" ]]; then
8082
pushd TestOnly >& /dev/null
8183
JDBC_VERSION=$($MVNW_EXE org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version --batch-mode | grep -v "[INFO]")

ci/scripts/check_content.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -o pipefail
88

99
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
1010

11-
if jar tvf $DIR/../../target/snowflake-jdbc${package_modifier}.jar | awk '{print $8}' | grep -v -E "/$" | grep -v -E "^(net|com)/snowflake" | grep -v -E "(com|net)/\$" | grep -v -E "^META-INF" | grep -v -E "^mozilla" | grep -v -E "^com/sun/jna" | grep -v com/sun/ | grep -v mime.types | grep -v -E "^com/github/luben/zstd/" | grep -v -E "^aix/" | grep -v -E "^darwin/" | grep -v -E "^freebsd/" | grep -v -E "^linux/" | grep -v -E "^win/"; then
11+
if jar $DIR/../../target/snowflake-jdbc${package_modifier}.jar | awk '{print $8}' | grep -v -E "/$" | grep -v -E "^(net|com)/snowflake" | grep -v -E "(com|net)/\$" | grep -v -E "^META-INF" | grep -v -E "^iso3166_" | grep -v -E "^mozilla" | grep -v -E "^com/sun/jna" | grep -v com/sun/ | grep -v mime.types | grep -v -E "^com/github/luben/zstd/" | grep -v -E "^aix/" | grep -v -E "^darwin/" | grep -v -E "^freebsd/" | grep -v -E "^linux/" | grep -v -E "^win/"; then
1212
echo "[ERROR] JDBC jar includes class not under the snowflake namespace"
1313
exit 1
1414
fi

ci/test_windows.bat

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ echo "MAVEN OPTIONS %MAVEN_OPTS%"
111111
REM Avoid connection timeout on plugin dependency fetch or fail-fast when dependency cannot be fetched
112112
cmd /c %MVNW_EXE% --batch-mode --show-version dependency:go-offline
113113

114+
set SF_ENABLE_EXPERIMENTAL_AUTHENTICATION=true
115+
114116
if "%JDBC_TEST_SUITES%"=="FipsTestSuite" (
115117
pushd FIPS
116118
echo "[INFO] Run Fips tests"

linkage-checker-exclusion-rules.xml

+21
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<Source><Package name="com.google.api.gax"/></Source>
3030
<Reason>?</Reason>
3131
</LinkageError>
32+
3233
<LinkageError>
3334
<Target><Package name="org.osgi"/></Target>
3435
<Source><Package name="org.apache.tika.config"/></Source>
@@ -49,6 +50,26 @@
4950
<Source><Package name="org.bouncycastle.pqc.legacy.crypto.ntru"/></Source>
5051
<Reason>?</Reason>
5152
</LinkageError>
53+
<LinkageError>
54+
<Target><Package name="org.cryptomator"/></Target>
55+
<Source><Package name="com.nimbusds"/></Source>
56+
<Reason>?</Reason>
57+
</LinkageError>
58+
<LinkageError>
59+
<Target><Package name="org.opensaml"/></Target>
60+
<Source><Package name="com.nimbusds"/></Source>
61+
<Reason>?</Reason>
62+
</LinkageError>
63+
<LinkageError>
64+
<Target><Package name="jakarta.servlet"/></Target>
65+
<Source><Package name="com.nimbusds"/></Source>
66+
<Reason>?</Reason>
67+
</LinkageError>
68+
<LinkageError>
69+
<Target><Package name="net.shibboleth.utilities"/></Target>
70+
<Source><Package name="com.nimbusds"/></Source>
71+
<Reason>?</Reason>
72+
</LinkageError>
5273
<!--
5374
<LinkageError>
5475
<Target><Package name=""/></Target>

parent-pom.xml

+13-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<apache.httpcore.version>4.4.16</apache.httpcore.version>
2222
<zstd-jni.version>1.5.6-5</zstd-jni.version>
2323
<arrow.version>17.0.0</arrow.version>
24-
<asm.version>9.3</asm.version>
24+
<asm.version>9.6</asm.version>
2525
<avro.version>1.8.1</avro.version>
2626
<awaitility.version>4.2.0</awaitility.version>
2727
<awssdk.version>1.12.655</awssdk.version>
@@ -60,16 +60,17 @@
6060
<javax.servlet.version>3.1.0</javax.servlet.version>
6161
<jna.version>5.13.0</jna.version>
6262
<joda.time.version>2.8.1</joda.time.version>
63-
<json.smart.version>2.4.9</json.smart.version>
63+
<json.smart.version>2.5.1</json.smart.version>
6464
<junit4.version>4.13.2</junit4.version>
6565
<junit.version>5.11.1</junit.version>
6666
<junit.platform.version>1.11.1</junit.platform.version>
6767
<jsoup.version>1.15.3</jsoup.version>
6868
<logback.version>1.3.6</logback.version>
6969
<metrics.version>2.2.0</metrics.version>
7070
<mockito.version>4.11.0</mockito.version>
71+
<nimbusds.oauth2.version>11.20.1</nimbusds.oauth2.version>
7172
<netty.version>4.1.118.Final</netty.version>
72-
<nimbusds.version>9.37.3</nimbusds.version>
73+
<nimbusds.version>9.40</nimbusds.version>
7374
<opencensus.version>0.31.1</opencensus.version>
7475
<plexus.container.version>1.0-alpha-9-stable-1</plexus.container.version>
7576
<plexus.utils.version>3.4.2</plexus.utils.version>
@@ -219,6 +220,11 @@
219220
<artifactId>nimbus-jose-jwt</artifactId>
220221
<version>${nimbusds.version}</version>
221222
</dependency>
223+
<dependency>
224+
<groupId>com.nimbusds</groupId>
225+
<artifactId>oauth2-oidc-sdk</artifactId>
226+
<version>${nimbusds.oauth2.version}</version>
227+
</dependency>
222228
<dependency>
223229
<groupId>com.yammer.metrics</groupId>
224230
<artifactId>metrics-core</artifactId>
@@ -657,6 +663,10 @@
657663
<groupId>com.nimbusds</groupId>
658664
<artifactId>nimbus-jose-jwt</artifactId>
659665
</dependency>
666+
<dependency>
667+
<groupId>com.nimbusds</groupId>
668+
<artifactId>oauth2-oidc-sdk</artifactId>
669+
</dependency>
660670
<dependency>
661671
<groupId>com.yammer.metrics</groupId>
662672
<artifactId>metrics-core</artifactId>

src/main/java/net/snowflake/client/config/SFClientConfigParser.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ public static SFClientConfig loadSFClientConfig(String configFilePath) throws IO
5858
derivedConfigFilePath = driverLocation;
5959
} else {
6060
// 4. Read SF_CLIENT_CONFIG_FILE_NAME if it is present in user home directory.
61-
String userHomeFilePath =
62-
Paths.get(systemGetProperty("user.home"), SF_CLIENT_CONFIG_FILE_NAME).toString();
63-
if (Files.exists(Paths.get(userHomeFilePath))) {
64-
logger.info("Using config file specified from home directory: {}", userHomeFilePath);
65-
derivedConfigFilePath = userHomeFilePath;
61+
String homeDirectory = systemGetProperty("user.home");
62+
if (homeDirectory != null) {
63+
String userHomeFilePath = Paths.get(homeDirectory, SF_CLIENT_CONFIG_FILE_NAME).toString();
64+
if (Files.exists(Paths.get(userHomeFilePath))) {
65+
logger.info("Using config file specified from home directory: {}", userHomeFilePath);
66+
derivedConfigFilePath = userHomeFilePath;
67+
}
6668
}
6769
}
6870
}

src/main/java/net/snowflake/client/core/AssertUtil.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public class AssertUtil {
1616
* @param internalErrorMesg The error message to display if condition is false
1717
* @throws SFException Will be thrown if condition is false
1818
*/
19-
static void assertTrue(boolean condition, String internalErrorMesg) throws SFException {
19+
@SnowflakeJdbcInternalApi
20+
public static void assertTrue(boolean condition, String internalErrorMesg) throws SFException {
2021
if (!condition) {
2122
throw new SFException(ErrorCode.INTERNAL_ERROR, internalErrorMesg);
2223
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2024-2025 Snowflake Computing Inc. All rights reserved.
3+
*/
4+
5+
package net.snowflake.client.core;
6+
7+
enum CachedCredentialType {
8+
ID_TOKEN("ID_TOKEN"),
9+
MFA_TOKEN("MFATOKEN"),
10+
OAUTH_ACCESS_TOKEN("OAUTH_ACCESS_TOKEN"),
11+
OAUTH_REFRESH_TOKEN("OAUTH_REFRESH_TOKEN");
12+
13+
private final String value;
14+
15+
CachedCredentialType(String value) {
16+
this.value = value;
17+
}
18+
19+
String getValue() {
20+
return value;
21+
}
22+
}

src/main/java/net/snowflake/client/core/Constants.java

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ public final class Constants {
2222
// Error code for all invalid id token cases during login request
2323
public static final int ID_TOKEN_INVALID_LOGIN_REQUEST_GS_CODE = 390195;
2424

25+
public static final int OAUTH_ACCESS_TOKEN_EXPIRED_GS_CODE = 390318;
26+
27+
public static final int OAUTH_ACCESS_TOKEN_INVALID_GS_CODE = 390303;
28+
2529
// Error message for IOException when no space is left for GET
2630
public static final String NO_SPACE_LEFT_ON_DEVICE_ERR = "No space left on device";
2731

0 commit comments

Comments
 (0)