Skip to content

Commit

Permalink
support snowflake mfa (#1326)
Browse files Browse the repository at this point in the history
* support mfa for snowflake client

* bump version
  • Loading branch information
pgrivachev authored Nov 1, 2023
1 parent 1766274 commit be5717e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Wizard for dbt Core (TM)",
"description": "This extension will help you work with dbt",
"icon": "images/Icon.png",
"version": "0.33.0",
"version": "0.33.1",
"publisher": "Fivetran",
"license": "MIT",
"preview": true,
Expand Down
4 changes: 3 additions & 1 deletion server/src/snowflake/SnowflakeKeyPairProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class SnowflakeKeyPairProfile implements DbtProfile {
database: z.string(),
warehouse: z.string(),
schema: z.string(),
client_session_keep_alive: z.optional(z.boolean()),
});

getDocsUrl(): string {
Expand Down Expand Up @@ -46,8 +47,9 @@ export class SnowflakeKeyPairProfile implements DbtProfile {
warehouse,
database,
schema,
client_session_keep_alive: clientSessionKeepAlive,
} = profile;
const connection = createConnection({ account, username, privateKeyPath, privateKeyPass, warehouse, database, schema });
const connection = createConnection({ account, username, privateKeyPath, privateKeyPass, warehouse, database, schema, clientSessionKeepAlive });

const client = new SnowflakeClient(database, connection);

Expand Down
15 changes: 13 additions & 2 deletions server/src/snowflake/SnowflakeUserPassProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class SnowflakeUserPassProfile implements DbtProfile {
database: z.string(),
warehouse: z.string(),
schema: z.string(),
authenticator: z.optional(z.string()),
client_session_keep_alive: z.optional(z.boolean()),
});

getDocsUrl(): string {
Expand All @@ -38,8 +40,17 @@ export class SnowflakeUserPassProfile implements DbtProfile {
}

private async createClientInternal(profile: z.infer<typeof SnowflakeUserPassProfile.SCHEMA>): Promise<Result<DbtDestinationClient, string>> {
const { account, user: username, password, warehouse, database, schema } = profile;
const connection = createConnection({ account, username, password, warehouse, database, schema });
const {
account,
user: username,
password,
warehouse,
database,
schema,
authenticator,
client_session_keep_alive: clientSessionKeepAlive,
} = profile;
const connection = createConnection({ account, username, password, warehouse, database, schema, authenticator, clientSessionKeepAlive });

const client = new SnowflakeClient(database, connection);

Expand Down
15 changes: 15 additions & 0 deletions server/src/test/profiles/snowflake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ correct_user_password:
warehouse: warehouse_name
schema: dbt_schema

correct_user_password_mfa:
target: dev
outputs:
dev:
type: snowflake
account: acc
user: username
password: password
role: role
database: database_name
warehouse: warehouse_name
schema: dbt_schema
authenticator: externalbrowser
client_session_keep_alive: True

user_password_missing_user:
target: dev
outputs:
Expand Down
4 changes: 4 additions & 0 deletions server/src/test/snowflake/SnowflakeUserPassProfile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ describe('SnowflakeUserPassProfile', () => {
shouldPassValidProfile(SNOWFLAKE_CONFIG, 'correct_user_password');
});

it('Should pass valid profile with MFA', () => {
shouldPassValidProfile(SNOWFLAKE_CONFIG, 'correct_user_password_mfa');
});

it('Should require user', () => {
shouldRequireField('user');
});
Expand Down

0 comments on commit be5717e

Please sign in to comment.