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-1694143: Fix sso token authentication #919

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,16 @@ declare module 'snowflake-sdk' {
*/
credentialCacheDir?: string;

/**
* The option to enable the MFA token. The default value is false.
*/
clientRequestMFAToken?: boolean;

/**
* The option to enable the SSO token. The default value is false.
*/
clientStoreTemporaryCredential?: boolean;

/**
* The option to include the passcode from DUO into the password.
*/
Expand All @@ -492,7 +502,7 @@ declare module 'snowflake-sdk' {
/**
* The option to pass passcode from DUO.
*/
passcode?: string
passcode?: string;
}

export interface Connection {
Expand Down
3 changes: 2 additions & 1 deletion lib/connection/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ function Connection(context) {
}

// Get authenticator to use
const auth = services.sf.getAuthenticator();
const auth = Authenticator.getAuthenticator(connectionConfig, context.getHttpClient());
services.sf.authenticator = auth;

try {
await initEasyLogging(connectionConfig.clientConfigFile);
Expand Down
11 changes: 5 additions & 6 deletions lib/services/sf.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,12 +1185,11 @@
numRetries,
};

auth.reauthenticate(context.options.json, retryOption).then(() => {
numRetries = retryOption.numRetries;
totalElapsedTime = retryOption.totalElapsedTime;
setTimeout(sendRequest, sleep * 1000);
return;
});
await auth.reauthenticate(context.options.json, retryOption);
numRetries = retryOption.numRetries;
totalElapsedTime = retryOption.totalElapsedTime;
setTimeout(sendRequest, sleep * 1000);
return;

Check warning on line 1192 in lib/services/sf.js

View check run for this annotation

Codecov / codecov/patch

lib/services/sf.js#L1188-L1192

Added lines #L1188 - L1192 were not covered by tests
} else {
if (auth instanceof AuthKeypair) {
Logger.getInstance().debug('AuthKeyPair authentication requires token refresh.');
Expand Down
Loading