Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1825482: PAT + OAuth Authorization Code + OAuth Client Credentials support #1978

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1741680
Draft OAuth authz code flow
sfc-gh-dheyman Nov 30, 2024
195ff36
Refactor
sfc-gh-dheyman Nov 30, 2024
a3dad01
Implement full flow
sfc-gh-dheyman Dec 2, 2024
0982aaf
Add wiremock test
sfc-gh-dheyman Dec 2, 2024
4acd8df
refactored
sfc-gh-dheyman Dec 3, 2024
214c98c
Add test scenarios
sfc-gh-dheyman Dec 3, 2024
dc55937
Added support for Okta oauth authorization code flow
sfc-gh-dheyman Dec 4, 2024
857d8a2
Add logs
sfc-gh-dheyman Dec 4, 2024
dc578a7
Merge branch 'master' into oauth-code-flow
sfc-gh-dheyman Dec 4, 2024
4662dfc
format
sfc-gh-dheyman Dec 4, 2024
c110329
Merge branch 'oauth-code-flow' of github.com:snowflakedb/snowflake-jd…
sfc-gh-dheyman Dec 4, 2024
06b0e24
reformat
sfc-gh-dheyman Dec 4, 2024
86d61ef
Fix shading
sfc-gh-dheyman Dec 4, 2024
c8de884
Extracted wiremock config to files
sfc-gh-dheyman Dec 4, 2024
77a9ce0
linkage checker
sfc-gh-dheyman Dec 5, 2024
9365dbf
CR suggestions applied
sfc-gh-dheyman Dec 5, 2024
971ba0d
CR suggestions applied
sfc-gh-dheyman Dec 5, 2024
538d61b
CR
sfc-gh-dheyman Dec 5, 2024
c8af6a8
Reformat
sfc-gh-dheyman Dec 5, 2024
b1b7854
Fix attempt at flaky wiremock tests
sfc-gh-dheyman Dec 5, 2024
26e67d6
Add internal api
sfc-gh-dheyman Dec 5, 2024
e32e81b
Merge branch 'master' of github.com:snowflakedb/snowflake-jdbc into o…
sfc-gh-dheyman Dec 6, 2024
e346a58
SNOW-1831099: OAuth Client Credentials Flow Implementation (#1993)
sfc-gh-dheyman Dec 10, 2024
05565c7
Merge branch 'master' of github.com:snowflakedb/snowflake-jdbc into o…
sfc-gh-dheyman Dec 10, 2024
1e4971c
Added copyright
sfc-gh-dheyman Dec 10, 2024
e8dc943
Refactor
sfc-gh-dheyman Dec 10, 2024
a45009a
SNOW-1825471: PAT authentication support (#1995)
sfc-gh-dheyman Dec 12, 2024
862b250
Add response from redirect server
sfc-gh-dheyman Dec 12, 2024
0312556
SNOW-1831103/SNOW-1853435: Refresh token & OAuth tokens caching suppo…
sfc-gh-dheyman Dec 20, 2024
53a307b
Merge branch 'master' into oauth-code-flow
sfc-gh-dheyman Dec 20, 2024
db9949c
Remove unnecessary import from AbstractDriverIT
sfc-gh-dheyman Dec 20, 2024
2b3328f
Add authorization code redirect request handler & tests
sfc-gh-dheyman Jan 2, 2025
cb7fad0
Refactor log
sfc-gh-dheyman Jan 2, 2025
a073c6b
CR suggestions applied
sfc-gh-dheyman Jan 8, 2025
5c9d8eb
Remove import
sfc-gh-dheyman Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FIPS/scripts/check_content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -o pipefail

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

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
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
echo "[ERROR] JDBC jar includes class not under the snowflake namespace"
exit 1
fi
2 changes: 1 addition & 1 deletion ci/scripts/check_content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o pipefail

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

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
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
echo "[ERROR] JDBC jar includes class not under the snowflake namespace"
exit 1
fi
Expand Down
21 changes: 21 additions & 0 deletions linkage-checker-exclusion-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<Source><Package name="com.google.api.gax"/></Source>
<Reason>?</Reason>
</LinkageError>

<LinkageError>
<Target><Package name="org.osgi"/></Target>
<Source><Package name="org.apache.tika.config"/></Source>
Expand All @@ -49,6 +50,26 @@
<Source><Package name="org.bouncycastle.pqc.legacy.crypto.ntru"/></Source>
<Reason>?</Reason>
</LinkageError>
<LinkageError>
<Target><Package name="org.cryptomator"/></Target>
<Source><Package name="com.nimbusds"/></Source>
<Reason>?</Reason>
</LinkageError>
<LinkageError>
<Target><Package name="org.opensaml"/></Target>
<Source><Package name="com.nimbusds"/></Source>
<Reason>?</Reason>
</LinkageError>
<LinkageError>
<Target><Package name="jakarta.servlet"/></Target>
<Source><Package name="com.nimbusds"/></Source>
<Reason>?</Reason>
</LinkageError>
<LinkageError>
<Target><Package name="net.shibboleth.utilities"/></Target>
<Source><Package name="com.nimbusds"/></Source>
<Reason>?</Reason>
</LinkageError>
<!--
<LinkageError>
<Target><Package name=""/></Target>
Expand Down
16 changes: 13 additions & 3 deletions parent-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<apache.httpcore.version>4.4.16</apache.httpcore.version>
<zstd-jni.version>1.5.6-5</zstd-jni.version>
<arrow.version>17.0.0</arrow.version>
<asm.version>9.3</asm.version>
<asm.version>9.6</asm.version>
<avro.version>1.8.1</avro.version>
<awaitility.version>4.2.0</awaitility.version>
<awssdk.version>1.12.655</awssdk.version>
Expand Down Expand Up @@ -60,7 +60,7 @@
<javax.servlet.version>3.1.0</javax.servlet.version>
<jna.version>5.13.0</jna.version>
<joda.time.version>2.8.1</joda.time.version>
<json.smart.version>2.4.9</json.smart.version>
<json.smart.version>2.5.1</json.smart.version>
<junit4.version>4.13.2</junit4.version>
<junit.version>5.11.1</junit.version>
<junit.platform.version>1.11.1</junit.platform.version>
Expand All @@ -69,7 +69,8 @@
<metrics.version>2.2.0</metrics.version>
<mockito.version>4.11.0</mockito.version>
<netty.version>4.1.115.Final</netty.version>
<nimbusds.version>9.37.3</nimbusds.version>
<nimbusds.version>9.40</nimbusds.version>
<nimbusds.oauth2.version>11.20.1</nimbusds.oauth2.version>
<opencensus.version>0.31.1</opencensus.version>
<plexus.container.version>1.0-alpha-9-stable-1</plexus.container.version>
<plexus.utils.version>3.4.2</plexus.utils.version>
Expand Down Expand Up @@ -219,6 +220,11 @@
<artifactId>nimbus-jose-jwt</artifactId>
<version>${nimbusds.version}</version>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
sfc-gh-dheyman marked this conversation as resolved.
Show resolved Hide resolved
<version>${nimbusds.oauth2.version}</version>
</dependency>
<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-core</artifactId>
Expand Down Expand Up @@ -646,6 +652,10 @@
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
</dependency>
<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-core</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/snowflake/client/core/AssertUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class AssertUtil {
* @param internalErrorMesg The error message to display if condition is false
* @throws SFException Will be thrown if condition is false
*/
static void assertTrue(boolean condition, String internalErrorMesg) throws SFException {
@SnowflakeJdbcInternalApi
public static void assertTrue(boolean condition, String internalErrorMesg) throws SFException {
if (!condition) {
throw new SFException(ErrorCode.INTERNAL_ERROR, internalErrorMesg);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2024 Snowflake Computing Inc. All rights reserved.
*/

package net.snowflake.client.core;

enum CachedCredentialType {
ID_TOKEN("ID_TOKEN"),
MFA_TOKEN("MFATOKEN"),
OAUTH_ACCESS_TOKEN("OAUTH_ACCESS_TOKEN"),
OAUTH_REFRESH_TOKEN("OAUTH_REFRESH_TOKEN");

private final String value;

CachedCredentialType(String value) {
this.value = value;
}

String getValue() {
return value;
}
}
4 changes: 4 additions & 0 deletions src/main/java/net/snowflake/client/core/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public final class Constants {
// Error code for all invalid id token cases during login request
public static final int ID_TOKEN_INVALID_LOGIN_REQUEST_GS_CODE = 390195;

public static final int OAUTH_ACCESS_TOKEN_EXPIRED_GS_CODE = 390318;

public static final int OAUTH_ACCESS_TOKEN_INVALID_GS_CODE = 390303;

// Error message for IOException when no space is left for GET
public static final String NO_SPACE_LEFT_ON_DEVICE_ERR = "No space left on device";

Expand Down
Loading
Loading