CREATE AUTHENTICATION POLICY¶

Creates a new authentication policy in the current or specified schema or replaces an existing authentication policy. You can use authentication policies to define authentication controls and security requirements for accounts or users.

See also:

ALTER AUTHENTICATION POLICY, DESCRIBE AUTHENTICATION POLICY, DROP AUTHENTICATION POLICY, SHOW AUTHENTICATION POLICIES

Syntax¶

CREATE [ OR REPLACE ] AUTHENTICATION POLICY [ IF NOT EXISTS ] <name>
  [ AUTHENTICATION_METHODS = ( '<string_literal>' [ , '<string_literal>' , ...  ] ) ]
  [ MFA_AUTHENTICATION_METHODS = ( '<string_literal>' [ , '<string_literal>' , ...  ] ) ]
  [ MFA_ENROLLMENT = { REQUIRED | OPTIONAL } ]
  [ CLIENT_TYPES = ( '<string_literal>' [ , '<string_literal>' , ...  ] ) ]
  [ SECURITY_INTEGRATIONS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
  [ COMMENT = '<string_literal>' ]
Copy

Required parameters¶

name

Specifies the identifier for the authentication policy. If the identifier contains spaces or special characters, you must enclose the string in double quotation marks. Identifiers enclosed in double quotation marks are case-sensitive. The identifier must meet the identifier requirements.

Optional parameters¶

AUTHENTICATION_METHODS = ( 'string_literal' [ , 'string_literal' , ... ] )

Caution

Restricting by authentication method can have unintended consequences, such as blocking driver connections or third-party integrations.

A list of authentication methods that are allowed during login. This parameter accepts one or more of the following values:

ALL

Allow all authentication methods.

SAML

Allows SAML2 security integrations. If SAML is present, an SSO login option appears. If SAML is not present, an SSO login option does not appear.

PASSWORD

Allows users to authenticate using username and password.

OAUTH

Allows External OAuth.

KEYPAIR

Allows Key pair authentication.

Default: ALL.

MFA_AUTHENTICATION_METHODS = ( 'string_literal' [ , 'string_literal' , ... ] )

A list of authentication methods that enforce multi-factor authentication (MFA) during login. Authentication methods not listed in this parameter do not prompt for multi-factor authentication.

The following authentication methods support MFA:

  • SAML

  • PASSWORD

This parameter accepts one or more of the following values:

SAML

Prompts users for MFA, if they are enrolled in MFA, when authenticating with SAML2 security integrations.

PASSWORD

Prompts users for MFA, if they are enrolled in MFA, when authenticating with a username and password.

Default: ('PASSWORD', 'SAML').

MFA_ENROLLMENT = { REQUIRED | OPTIONAL }

Determines whether a user must enroll in multi-factor authentication.

REQUIRED

Enforces users to enroll in MFA. If this value is used, then the CLIENT_TYPES parameter must include SNOWFLAKE_UI, because Snowsight is the only place users can enroll in multi-factor authentication (MFA).

OPTIONAL

Users can choose whether to enroll in MFA.

Default: OPTIONAL.

CLIENT_TYPES = ( 'string_literal' [ , 'string_literal' , ... ] )

A list of clients that can authenticate with Snowflake. If a client tries to connect, and the client is not one of the valid CLIENT_TYPES, then the login attempt fails.

The CLIENT_TYPES property of an authentication policy is a best effort method to block user logins based on specific clients. It should not be used as the sole control to establish a security boundary.

This parameter accepts one or more of the following values:

ALL

Allow all clients to authenticate.

SNOWFLAKE_UI

Snowsight or Classic Console, the Snowflake web interfaces.

Caution

If SNOWFLAKE_UI is not included in the CLIENT_TYPES list, MFA enrollment does not work.

DRIVERS

Drivers allow access to Snowflake from applications written in supported languages. For example, the Go, JDBC, .NET drivers, and Snowpipe Streaming.

Caution

If DRIVERS is not included in the CLIENT_TYPES list, automated ingestion may stop working.

SNOWSQL

A command-line client for connecting to Snowflake.

Default: ALL.

SECURITY_INTEGRATIONS = ( 'string_literal' [ , 'string_literal' , ... ] )

A list of security integrations the authentication policy is associated with. This parameter has no effect when SAML or OAUTH are not in the AUTHENTICATION_METHODS list.

All values in the SECURITY_INTEGRATIONS list must be compatible with the values in the AUTHENTICATION_METHODS list. For example, if SECURITY_INTEGRATIONS contains a SAML security integration, and AUTHENTICATION_METHODS contains OAUTH, then you cannot create the authentication policy.

ALL

Allow all security integrations.

Default: ALL.

COMMENT = 'string_literal'

Specifies a description of the policy.

Access control requirements¶

A role used to execute this SQL command must have the following privileges at a minimum:

Privilege

Object

Notes

CREATE AUTHENTICATION POLICY

Schema

Only the SECURITYADMIN role, or a higher role, has this privilege by default. The privilege can be granted to additional roles as needed.

Note that operating on any object in a schema also requires the USAGE privilege on the parent database and schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Usage notes¶

  • After creating an authentication policy, you must use the ALTER ACCOUNT or ALTER USER command to set it on an account or user before Snowflake enforces the policy.

  • If you want to update an existing authentication policy and need to see the definition of the policy, run the DESCRIBE AUTHENTICATION POLICY command or GET_DDL function.

  • CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.

Example¶

Create an authentication policy named restrict_client_types_policy that only allows access through Snowsight or the Classic Console:

CREATE AUTHENTICATION POLICY restrict_client_types_policy
  CLIENT_TYPES = ('SNOWFLAKE_UI')
  COMMENT = 'Auth policy that only allows access through the web interface';
Copy

For more examples, see Authentication policies.