Multi-Factor Authentication (MFA)

Snowflake supports multi-factor authentication (i.e. MFA) to provide increased login security for users connecting to Snowflake. MFA support is provided as an integrated Snowflake feature, powered by the Duo Security service, which is managed completely by Snowflake.

Users do not need to separately sign up with Duo or perform any tasks, other than installing the Duo Mobile application, which is supported on multiple smart phone platforms (iOS, Android, Windows, etc.). See the Duo User Guide for more information about supported platforms/devices and how Duo multi-factor authentication works.

MFA is enabled on a per-user basis; however, at this time, users are not automatically enrolled in MFA. To use MFA, users must enroll themselves.

Attention

At a minimum, Snowflake strongly recommends that all users with the ACCOUNTADMIN role be required to use MFA.

In this Topic:

Prerequisite

The Duo application service communicates through TCP port 443.

To ensure consistent behavior, update your firewall settings to include the Duo application service on TCP port 443.

*.duosecurity.com:443

For more information, see the Duo documentation.

MFA Login Flow

The following diagram illustrates the overall login flow for a user enrolled in MFA, regardless of the interface used to connect:

MFA login flow

Enrolling a Snowflake User in MFA

Any Snowflake user can self-enroll in MFA through the web interface. For more information, see Managing Your User Preferences.

Managing MFA for Your Account and Users

At the account level, MFA requires no management. It is automatically enabled for your account and available for all your users to self-enroll. However, you may find the need to disable MFA for a user, either temporarily or permanently, for example if the user loses their phone or changes their phone number and cannot log in with MFA.

You can use the following properties for the ALTER USER command to perform these tasks:

  • MINS_TO_BYPASS_MFA

    Specifies the number of minutes to temporarily disable MFA for the user so that they can log in. After the time passes, MFA is enforced and the user cannot log in without the temporary token generated by the Duo Mobile application.

  • DISABLE_MFA

    Disables MFA for the user, effectively canceling their enrollment. To use MFA again, the user must re-enroll.

    Note

    DISABLE_MFA is not a column in any Snowflake table or view. After an account administrator executes the ALTER USER command to set DISABLE_MFA to TRUE, the value for the EXT_AUTHN_DUO property is automatically set to FALSE.

    To verify that MFA is disabled for a given user, execute a DESCRIBE USER statement and check the value for the EXT_AUTHN_DUO property.

Connecting to Snowflake with MFA

MFA login is designed primarily for connecting to Snowflake through the web interface, but is also fully-supported by SnowSQL and the Snowflake JDBC and ODBC drivers.

Using MFA Token Caching to Minimize the Number of Prompts During Authentication — Optional

MFA token caching can help to reduce the number of prompts that must be acknowledged while connecting and authenticating to Snowflake, especially when multiple connection attempts are made within a relatively short time interval.

A cached MFA token is valid for up to four hours.

The cached MFA token is invalid if any of the following conditions are met:

  1. The ALLOW_CLIENT_MFA_CACHING parameter is set to FALSE for the account or user.

  2. The method of authentication changes.

  3. The authentication credentials change (i.e. username and/or password).

  4. The authentication credentials are not valid.

  5. The cached token expires or is not cryptographically valid.

  6. The account name associated with the cached token changes.

The overall process Snowflake uses to cache MFA tokens is similar to that used to cache connection tokens for browser-based federated single sign-on. The client application stores the MFA token in the keystore of the client-side operating system. Users can delete the cached MFA token from the keystore at any time.

Snowflake supports MFA token caching with the following client versions:

  • ODBC driver version 2.23.0 (or later).

  • JDBC driver version 3.12.16 (or later).

  • Python Connector for Snowflake version 2.3.7 (or later).

Snowflake recommends consulting with internal security and compliance officers prior to enabling MFA token caching.

Tip

MFA token caching can be combined with connection caching in federated single sign-on.

To combine these two features, ensure that the ALLOW_ID_TOKEN parameter is set to true in tandem with the ALLOW_CLIENT_MFA_CACHING parameter.

To enable MFA token caching, complete the following steps:

  1. As an account administrator (i.e. a user with the ACCOUNTADMIN system role), set the ALLOW_CLIENT_MFA_CACHING parameter to true for an account using the ALTER ACCOUNT command or a user by using the ALTER USER command.

    -- account-level
    
    alter account set allow_client_mfa_caching = true;
    
  2. In the client connection string, update the authenticator value to authenticator = username_password_mfa.

  3. Add the package or libraries needed by the driver or connector:

    • If you are using the Snowflake Connector for Python, install the optional keyring package by running:

      pip install "snowflake-connector-python[secure-local-storage]"
      

      You must enter the square brackets ([ and ]) as shown in the command. The square brackets specify the extra part of the package that should be installed.

      Use quotes around the name of the package as shown to prevent the square brackets from being interpreted as a wildcard.

      If you need to install other extras (for example, pandas for using the Python Connector APIs for Pandas), use a comma between the extras:

      pip install "snowflake-connector-python[secure-local-storage,pandas]"
      
    • For the Snowflake JDBC Driver, see Adding the JNA Classes to Your Classpath.

To disable MFA token caching, unset the ALLOW_CLIENT_MFA_CACHING parameter.

Using MFA with the Web Interface

To log into the Snowflake web interface with MFA:

  1. Point your browser at the URL for your account (e.g. https://xy12345.snowflakecomputing.com, https://xy12345.eu-central-1.snowflakecomputing.com).

  2. Enter your credentials (user login name and password).

    MFA login
  3. If Duo Push is enabled, a push notification is sent to your Duo Mobile application. When you receive the notification, simply click Approve and you will be logged into Snowflake.

    MFA approval

    As shown on the above screenshot, instead of using the push notification, you can also choose to:

    • Click Call Me to receive login instructions from a phone call to the registered mobile device

    • Click Enter a Passcode to log in by manually entering a passcode provided by the Duo Mobile application.

Using MFA with SnowSQL

MFA can be used for connecting to Snowflake through SnowSQL. By default, the Duo Push authentication mechanism is used when a user is enrolled in MFA.

To use a Duo-generated passcode instead of the push mechanism, the login parameters must include one of the following connection options:

--mfa-passcode <string> OR --mfa-passcode-in-password

For more details, see SnowSQL (CLI Client).

Using MFA with JDBC

MFA can be used for connecting to Snowflake via the Snowflake JDBC driver. By default, the Duo Push authentication mechanism is used when a user is enrolled in MFA; no changes to the JDBC connection string are required.

To use a Duo-generated passcode instead of the push mechanism, one of the following parameters must be included in the JDBC connection string:

passcode=<passcode_string> OR passcodeInPassword=on

Where:

  • passcode_string is a Duo-generated passcode for the user who is connecting. This can be a passcode generated by the Duo Mobile application or an SMS passcode.

  • If passcodeInPassword=on, then the password and passcode are concatenated, in the form of <password_string><passcode_string>.

For more details, see JDBC Driver.

Examples of JDBC Connection Strings Using Duo

JDBC connection string for user demo connecting to the xy12345 account (in the US West region) using a Duo passcode:

jdbc:snowflake://xy12345.snowflakecomputing.com/?user=demo&passcode=123456

JDBC connection string for user demo connecting to the xy12345 account (in the US West region) using a Duo passcode that is embedded in the password:

jdbc:snowflake://xy12345.snowflakecomputing.com/?user=demo&passcodeInPassword=on

Using MFA with ODBC

MFA can be used for connecting to Snowflake via the Snowflake ODBC driver. By default, the Duo Push authentication mechanism is used when a user is enrolled in MFA; no changes to the ODBC settings are required.

To use a Duo-generated passcode instead of the push mechanism, one of the following parameters must be specified for the driver:

passcode=<passcode_string> OR passcodeInPassword=on

Where:

  • passcode_string is a Duo-generated passcode for the user who is connecting. This can be a passcode generated by the Duo Mobile application or an SMS passcode.

  • If passcodeInPassword=on, then the password and passcode are concatenated, in the form of <password_string><passcode_string>.

For more details, see ODBC Driver.

Using MFA with Python

MFA can be used for connecting to Snowflake via the Snowflake Python Connector. By default, the Duo Push authentication mechanism is used when a user is enrolled in MFA; no changes to the Python API calls are required.

To use a Duo-generated passcode instead of the push mechanism, one of the following parameters must be specified for the driver in the connect() method:

passcode=<passcode_string> OR passcode_in_password=True

Where:

  • passcode_string is a Duo-generated passcode for the user who is connecting. This can be a passcode generated by the Duo Mobile application or an SMS passcode.

  • If passcode_in_password=True, then the password and passcode are concatenated, in the form of <password_string><passcode_string>.

For more details, see the description of the connect() method in the Functions section of the Python Connector API documentation.

MFA Error Codes

The following are error codes associated with MFA that can be returned during the authentication flow.

The errors are displayed with each failed login attempt. Historical data is also available in Information Schema and Account Usage:

Error Code

Error

Description

390120

EXT_AUTHN_DENIED

Duo Security authentication is denied.

390121

EXT_AUTHN_PENDING

Duo Security authentication is pending.

390122

EXT_AUTHN_NOT_ENROLLED

User is not enrolled in Duo Security. Contact your local system administrator.

390123

EXT_AUTHN_LOCKED

User is locked from Duo Security. Contact your local system administrator.

390124

EXT_AUTHN_REQUESTED

Duo Security authentication is required.

390125

EXT_AUTHN_SMS_SENT

Duo Security temporary passcode is sent via SMS. Please authenticate using the passcode.

390126

EXT_AUTHN_TIMEOUT

Timed out waiting for your login request approval via Duo Mobile. If your mobile device has no data service, generate a Duo passcode and enter it in the connect string.

390127

EXT_AUTHN_INVALID

Incorrect passcode was specified.

390128

EXT_AUTHN_SUCCEEDED

Duo Security authentication is successful.

390129

EXT_AUTHN_EXCEPTION

Request could not be completed due to a communication problem with the external service provider. Try again later.

390132

EXT_AUTHN_DUO_PUSH_DISABLED

Duo Push is not enabled for your MFA. Provide a passcode as part of the connection string.