Skip to content

Commit

Permalink
SNOW-1694143: Fix sso token authentication (#919) (Co-authored-by: su…
Browse files Browse the repository at this point in the history
…permacro)
  • Loading branch information
sfc-gh-ext-simba-jy authored Oct 1, 2024
1 parent b624a8f commit 852017f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
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 @@ StateConnecting.prototype.continue = function () {
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;
} else {
if (auth instanceof AuthKeypair) {
Logger.getInstance().debug('AuthKeyPair authentication requires token refresh.');
Expand Down

0 comments on commit 852017f

Please sign in to comment.