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.
This command supports the following variants:
CREATE OR ALTER AUTHENTICATION POLICY: Creates an authentication policy if it doesn’t exist, or alters an existing authentication policy.
- See also:
ALTER AUTHENTICATION POLICY, DESCRIBE AUTHENTICATION POLICY, DROP AUTHENTICATION POLICY, SHOW AUTHENTICATION POLICIES, CREATE OR ALTER <object>
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 } ]
[ MFA_POLICY= ( ALLOWED_METHODS = ( { 'ALL' | 'PASSKEY' | 'TOTP' | 'DUO' } [ , { 'PASSKEY' | 'TOTP' | 'DUO' } ... ] ) ) ]
[ CLIENT_TYPES = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ SECURITY_INTEGRATIONS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ PAT_POLICY = ( <list_of_properties> ) ]
[ WORKLOAD_IDENTITY_POLICY = ( <list_of_properties> ) ]
[ COMMENT = '<string_literal>' ]
Variant syntax¶
CREATE OR ALTER AUTHENTICATION POLICY¶
Creates a new authentication policy if it doesn’t already exist, or alters an existing authentication policy into the one defined in the statement. A CREATE OR ALTER AUTHENTICATION POLICY statement follows the syntax rules of a CREATE AUTHENTICATION POLICY statement and has the same limitations as an ALTER AUTHENTICATION POLICY statement.
CREATE OR ALTER AUTHENTICATION POLICY <name>
[ AUTHENTICATION_METHODS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ MFA_AUTHENTICATION_METHODS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ MFA_ENROLLMENT = { REQUIRED | OPTIONAL } ]
[ MFA_POLICY= ( ALLOWED_METHODS = ( { 'ALL' | 'PASSKEY' | 'TOTP' | 'DUO' } [ , { 'ALL' | 'PASSKEY' | 'TOTP' | 'DUO' } ... ] ) ) ]
[ CLIENT_TYPES = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ SECURITY_INTEGRATIONS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ PAT_POLICY = ( {list_of_properties} ) ]
[ WORKLOAD_IDENTITY_POLICY = ( {list_of_properties} ) ]
[ COMMENT = '<string_literal>' ]
Required parameters¶
nameSpecifies the identifier for the authentication policy.
In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example,
"My object"). Identifiers enclosed in double quotes are also case-sensitive.For more information, see 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:
ALLAllow all authentication methods.
SAMLAllows SAML2 security integrations. If
SAMLis present, an SSO login option appears. IfSAMLis not present, an SSO login option does not appear.PASSWORDAllows users to authenticate using username and password.
OAUTHAllows External OAuth.
KEYPAIRAllows Key pair authentication.
PROGRAMMATIC_ACCESS_TOKENAllows users to authenticate with a programmatic access token.
WORKLOAD_IDENTITYAllows users to authenticate through workload identity federation.
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:
SAMLPASSWORD
This parameter accepts one or more of the following values:
SAMLPrompts users for MFA, if they are enrolled in MFA, when authenticating with SAML2 security integrations.
PASSWORDPrompts users for MFA, if they are enrolled in MFA, when authenticating with a username and password.
Default:
('PASSWORD').MFA_ENROLLMENT = { REQUIRED | OPTIONAL }Determines whether a user must enroll in multi-factor authentication.
REQUIREDEnforces users to enroll in MFA. If this value is used, then the
CLIENT_TYPESparameter must includeSNOWFLAKE_UI, because Snowsight is the only place users can enroll in multi-factor authentication (MFA).OPTIONALUsers can choose whether to enroll in MFA.
Default:
OPTIONAL. For backwards compatibility, you can create an authentication policy without specifying anMFA_ENROLLMENTvalue, but the actual value that is enforced won’t beOPTIONALbecause Snowflake is moving toward requiring MFA for all human users. To determine which value is being enforced for an existing authentication policy, run the DESCRIBE AUTHENTICATION POLICY command.MFA_POLICY= ( ALLOWED_METHODS = ( { 'ALL' | 'PASSKEY' | 'TOTP' | 'DUO' } [ , { 'PASSKEY' | 'TOTP' | 'DUO' } ... ] ) )Specifies the multi-factor authentication (MFA) methods that users can use as a second factor of authentication. You can specify more than one method.
ALLUsers can use a passkey, an authenticator app, or Duo as their second factor of authentication.
PASSKEYUsers can use a passkey as their second factor of authentication.
TOTPUsers can use an authenticator app as their second factor of authentication.
DUOUsers can use Duo as their second factor of authentication.
Default:
ALL.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_TYPESvalues listed below, then the login attempt fails.If you set
MFA_ENROLLMENTtoREQUIRED, then you must includeSNOWFLAKE_UIin theCLIENT_TYPESlist to allow users to enroll in MFA.If you want to exclude
SNOWFLAKE_UIfrom theCLIENT_TYPESlist, then you must setMFA_ENROLLMENTtoOPTIONAL.The
CLIENT_TYPESproperty 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. Notably, it does not restrict access to the Snowflake REST APIs..This parameter accepts one or more of the following values:
ALLAllow all clients to authenticate.
SNOWFLAKE_UISnowsight or Classic Console, the Snowflake web interfaces.
Caution
If
SNOWFLAKE_UIis not included in theCLIENT_TYPESlist whileMFA_ENROLLMENTis set toREQUIRED, orMFA_ENROLLMENTis unspecified, MFA enrollment doesn’t work.DRIVERSDrivers allow access to Snowflake from applications written in supported languages. For example, the Go, JDBC, .NET drivers, and Snowpipe Streaming.
Caution
If
DRIVERSis not included in theCLIENT_TYPESlist, automated ingestion may stop working.SNOWFLAKE_CLIA command-line client for connecting to Snowflake and for managing developer-centric workloads and SQL operations.
SNOWSQLA 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
SAMLorOAUTHare not in theAUTHENTICATION_METHODSlist.All values in the
SECURITY_INTEGRATIONSlist must be compatible with the values in theAUTHENTICATION_METHODSlist. For example, ifSECURITY_INTEGRATIONScontains a SAML security integration, andAUTHENTICATION_METHODScontainsOAUTH, then you cannot create the authentication policy.ALLAllow all security integrations.
Default:
ALL.
PAT_POLICY = ( list_of_properties )Specifies the policies for programmatic access tokens. Set this to a space-delimited list of one or more of the following properties and values:
DEFAULT_EXPIRY_IN_DAYS = number_of_daysSpecifies the default expiration time (in days) for a programmatic access token. You can specify a value from 1 to the maximum expiration time (which you can specify by setting MAX_EXPIRY_IN_DAYS).
The default expiration time is 15 days.
For more information, see Setting the default expiration time.
MAX_EXPIRY_IN_DAYS = number_of_daysSpecifies the maximum number of days that can be set for the expiration time for a programmatic access token. You can specify a value from the default expiration time (which you can specify by setting DEFAULT_EXPIRY_IN_DAYS) to 365.
The default maximum expiration time is 365 days.
Note
If there are existing programmatic access tokens with expiration times that exceed the new maximum expiration time, attempts to authenticate with those tokens will fail.
For example, suppose that you generate a programmatic access token named
my_tokenwith the expiration time of 7 days. If you later change the maximum expiration time for all tokens to 2 days, authenticating withmy_tokenwill fail because the expiration time of the token exceeds the new maximum expiration time.For more information, see Setting the maximum expiration time.
NETWORK_POLICY_EVALUATION = { ENFORCED_REQUIRED | ENFORCED_NOT_REQUIRED | NOT_ENFORCED }Specifies how network policy requirements are handled for programmatic access tokens.
By default, a user must be subject to a network policy with one or more network rules to generate or use programmatic access tokens:
Service users (with TYPE=SERVICE) must be subject to a network policy to generate and use programmatic access tokens.
Human users (with TYPE=PERSON) must be subject to a network policy to use programmatic access tokens.
To override this behavior, set this property to one of the following values:
ENFORCED_REQUIRED(default behavior)The user must be subject to a network policy to generate and use programmatic access tokens.
If the user is subject to a network policy, the network policy is enforced during authentication.
ENFORCED_NOT_REQUIREDThe user does not need to be subject to a network policy to generate and use programmatic access tokens.
If the user is subject to a network policy, the network policy is enforced during authentication.
NOT_ENFORCEDThe user does not need to be subject to a network policy to generate and use programmatic access tokens.
If the user is subject to a network policy, the network policy is not enforced during authentication.
For example:
PAT_POLICY=( DEFAULT_EXPIRY_IN_DAYS=30 MAX_EXPIRY_IN_DAYS=365 NETWORK_POLICY_EVALUATION = ENFORCED_NOT_REQUIRED );
WORKLOAD_IDENTITY_POLICY = ( list_of_properties )Specifies the policies for workload identity federation. Set this to a space-delimited list that contains one or more of the following properties and values:
ALLOWED_PROVIDERS = ( { ALL | AWS | AZURE | GCP | OIDC } [ , { AWS | AZURE | GCP | OIDC } ... ] )Specifies the workload identity providers allowed by the authentication policy during workload identity authentication. If this parameter is omitted, all workload identity providers are allowed.
ALLUsers can authenticate with any supported and configured workload identity provider.
AWSUsers can authenticate with an AWS IAM role or user.
AZUREUsers can authenticate with an Azure Entra ID access token.
GCPUsers can authenticate with a Google-signed ID token.
OIDCUsers can authenticate with an ID token from a configured OIDC provider.
ALLOWED_AWS_ACCOUNTS = ( 'string_literal' [ , 'string_literal' , ... ] )Specifies the list of AWS account IDs allowed by the authentication policy during workload identity authentication of type
AWS.By default, when a Snowflake service user has a
WORKLOAD_IDENTITYof typeAWS, then the ARN can reference any AWS account. If this parameter is set, then only ARNs from the specified AWS account IDs are allowed to authenticate.Each element must be a 12-digit string representing the AWS account ID.
For more information, see View AWS account identifiers.
ALLOWED_AZURE_ISSUERS = ( 'string_literal' [ , 'string_literal' , ... ] )Specifies the list of Azure Entra ID issuers allowed by the authentication policy during workload identity authentication of type
AZURE.By default, when a Snowflake service user has a
WORKLOAD_IDENTITYof typeAZURE, then the issuer can be any Entra ID tenant. If this parameter is set, then only Azure tokens from the specified issuers are allowed to authenticate.Each element must be a valid Authority URL with following format:
https://login.microsoftonline.com/tenantId/v2.0
ALLOWED_OIDC_ISSUERS = ( 'string_literal' [ , 'string_literal' , ... ] )Specifies the list of OIDC issuers allowed by the authentication policy during workload identity authentication of type
OIDC.By default, when a Snowflake service user has a
WORKLOAD_IDENTITYof typeOIDC, then the issuer can be any valid OIDC issuer. If this parameter is set, then only tokens from the specified OIDC issuers are allowed to authenticate.Each element must be a valid HTTPS URL that contains scheme, host, and optionally, port number and path components but no query or fragment components. The URL must not contain spaces, and it must not exceed 2048 characters in length.
For example:
WORKLOAD_IDENTITY_POLICY=( ALLOWED_PROVIDERS = (AWS, AZURE, GCP, OIDC) ALLOWED_AWS_ACCOUNTS = ('123456789012', '210987654321') ALLOWED_AZURE_ISSUERS = ('https://login.microsoftonline.com/8c7832f5-de56-4d9f-ba94-3b2c361abe6b/v2.0', 'https://login.microsoftonline.com/9ebd1ec9-9a78-4429-8f53-5cf870a812d1/v2.0') ALLOWED_OIDC_ISSUERS = ('https://my.custom.oidc.issuer/', 'https://another.custom/oidc/issuer') );
COMMENT = 'string_literal'Specifies a description of the policy.
Access control requirements¶
A role used to execute this operation must have the following privileges at a minimum:
Privilege |
Object |
Notes |
|---|---|---|
CREATE AUTHENTICATION POLICY |
Schema |
|
OWNERSHIP |
Authentication Policy |
|
The USAGE privilege on the parent database and schema are required to perform operations on any object in a schema. Note that a role granted any privilege on a schema allows that role to resolve the schema. For example, a role granted CREATE privilege on a schema can create objects on that schema without also having USAGE granted on that 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.
The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement.
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';
Set multi-factor authentication and update the list of clients:
CREATE OR ALTER AUTHENTICATION POLICY restrict_client_types_policy
MFA_ENROLLMENT = REQUIRED
MFA_AUTHENTICATION_METHODS = ('PASSWORD', 'SAML')
CLIENT_TYPES = ('SNOWFLAKE_UI', 'SNOWFLAKE_CLI');
For more examples, see Authentication policies.