CREATE AUTHENTICATION POLICY
statementsupportedGovernance (policies, tags, data quality)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. - DEFINE AUTHENTICATION POLICY: Declarative definition of an authentication policy’s target state inside a DCM project.
Syntax
supportedpartialnot supportednot scored
CREATE [ OR REPLACE ] AUTHENTICATION POLICY [ IF NOT EXISTS ] <name>
[ AUTHENTICATION_METHODS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ CLIENT_TYPES = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ CLIENT_POLICY = ( <client_type> = ( MINIMUM_VERSION = '<version>' ) [ , ... ] ) ]
[ SECURITY_INTEGRATIONS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ MFA_ENROLLMENT = { 'REQUIRED' | 'REQUIRED_PASSWORD_ONLY' | 'OPTIONAL' } ]
[ MFA_POLICY = ( <list_of_properties> ) ]
[ PAT_POLICY = ( <list_of_properties> ) ]
[ WORKLOAD_IDENTITY_POLICY = ( <list_of_properties> ) ]
[ COMMENT = '<string_literal>' ]
For more information, see CREATE OR ALTER <object>.
CREATE OR ALTER AUTHENTICATION POLICY <name>
[ AUTHENTICATION_METHODS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ CLIENT_TYPES = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ CLIENT_POLICY = ( <client_type> = ( MINIMUM_VERSION = '<version>' ) [ , ... ] ) ]
[ SECURITY_INTEGRATIONS = ( '<string_literal>' [ , '<string_literal>' , ... ] ) ]
[ MFA_ENROLLMENT = { 'REQUIRED' | 'REQUIRED_PASSWORD_ONLY' | 'OPTIONAL' } ]
[ MFA_POLICY = ( <list_of_properties> ) ]
[ PAT_POLICY = ( <list_of_properties> ) ]
[ WORKLOAD_IDENTITY_POLICY = ( <list_of_properties> ) ]
[ COMMENT = '<string_literal>' ]
Parameters
| Name | Required | Description |
|---|---|---|
name | required | Specifies 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. |
AUTHENTICATION_METHODS = ( 'string_literal' [ , 'string_literal' , ... ] ) | optional | 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: Default: ALL.
|
CLIENT_TYPES = ( 'string_literal' [ , 'string_literal' , ... ] ) | optional | 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 values listed below, then the login attempt fails. If you set MFA_ENROLLMENT to REQUIRED, then you must include SNOWFLAKE_UI in the CLIENT_TYPES list to allow users to enroll in MFA. If you want to exclude SNOWFLAKE_UI from the CLIENT_TYPES list, then you must set MFA_ENROLLMENT to OPTIONAL. 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. Notably, it does not restrict access to the Snowflake REST APIs. This parameter accepts one or more of the following values: Default: ALL.
|
CLIENT_POLICY = client_type = ( MINIMUM_VERSION = 'version' ) | optional | Specifies a policy within the authentication policy that sets the minimum version allowed for each specified client type. If CLIENT_TYPES is empty, contains ALL, or contains DRIVERS, the CLIENT_POLICY parameter accepts one or more of the following driver clients (and a specific version string). For any driver client that is not specified, the policy implicitly allows any version of that client. If CLIENT_TYPES contains another value, such as SNOWFLAKE_CLI, and does not also contain DRIVERS, specifying any of the following client types results in an error. You can’t create (or alter) an authentication policy such that the CLIENT_TYPES and CLIENT_POLICY parameters aren’t compatible. The CLIENT_POLICY property of an authentication policy is a best-effort method to block user logins based on specific client versions. It should not be used as the sole control to establish a security boundary.
|
SECURITY_INTEGRATIONS = ( 'string_literal' [ , 'string_literal' , ... ] ) | optional | A list of security integrations the authentication policy is associated with. This parameter has no effect when SAML, OIDC, 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. Similarly, if SECURITY_INTEGRATIONS contains an OIDC security integration, and AUTHENTICATION_METHODS contains SAML only, then you cannot create the authentication policy. Default: ALL.
|
MFA_ENROLLMENT = { 'REQUIRED' | 'REQUIRED_PASSWORD_ONLY' | 'OPTIONAL' } | optional | Determines whether a user must enroll in multi-factor authentication. CLIENT_TYPES must include SNOWFLAKE_UI only for interactive authentication, when users sign in through the Snowflake login UI. This requirement does not apply to non-interactive authentication. It’s possible for the value of the MFA_ENROLLMENT parameter to be REQUIRED_SNOWFLAKE_UI_PASSWORD_ONLY. This value is part of Snowflake’s gradual deprecation of single-factor passwords, and cannot be set directly. If you run a DESCRIBE AUTHENTICATION POLICY command and MFA_ENROLLMENT = 'REQUIRED_SNOWFLAKE_UI_PASSWORD_ONLY', then password users must enroll in MFA if they are using Snowsight. Default: OPTIONAL. On accounts created after the Multi-factor authentication enrollment enforced by default for new Snowflake accounts behavior change, Snowflake applies a built-in authentication policy that enforces MFA enrollment. If you omit MFA_ENROLLMENT on one of those accounts, the enforced value is REQUIRED, not OPTIONAL. Include SNOWFLAKE_UI in CLIENT_TYPES only when that policy is for interactive authentication through the Snowflake login UI. The requirement does not apply to non-interactive clients, such as DRIVERS. To see the value enforced on an existing policy, run the DESCRIBE AUTHENTICATION POLICY command.
|
MFA_POLICY= ( list_of_properties ) | optional | Specifies the policies that affect how multi-factor authentication (MFA) is enforced. Set this to a space-delimited list of one or more of the following properties and values: |
ALLOWED_METHODS = ( { 'ALL' | 'PASSKEY' | 'TOTP' | 'OTP' | 'DUO' } [ , { 'PASSKEY' | 'TOTP' | 'OTP' | '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 as a comma-delimited list. Default: ALL.
| |
ENFORCE_MFA_ON_EXTERNAL_AUTHENTICATION = { 'ALL' | 'NONE' } | Specifies whether multi-factor authentication (MFA) is required when users authenticate with single sign-on (SSO). To require MFA, specify ALL. Default: NONE | |
PAT_POLICY = ( list_of_properties ) | optional | Specifies the policies for programmatic access tokens. Set this to a space-delimited list of one or more of the following properties and values: The following example of the PAT_POLICY clause specifies the following policy: By default, programmatic access tokens expire in 30 days. Programmatic access tokens have a maximum expiration time of 365 days. You can generate a programmatic access token for a user if the user is not subject to a network policy requirement. Any network policy that the user is subject to is still enforced. When you generate a programmatic access token for a service user, you do not need to restrict to token to use a specific role. Copy code PAT_POLICY=( DEFAULT_EXPIRY_IN_DAYS=30 MAX_EXPIRY_IN_DAYS=365 NETWORK_POLICY_EVALUATION = ENFORCED_NOT_REQUIRED REQUIRE_ROLE_RESTRICTION_FOR_SERVICE_USERS = FALSE ); |
DEFAULT_EXPIRY_IN_DAYS = number_of_days | Specifies 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_days | Specifies 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_token with the expiration time of 7 days. If you later change the maximum expiration time for all tokens to 2 days, authenticating with my_token will 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:
| |
REQUIRE_ROLE_RESTRICTION_FOR_SERVICE_USERS = { TRUE | FALSE } | If TRUE, when you generate a programmatic access token for a service user, you must restrict the use of that token to a specific role. If you set this parameter to FALSE, you can generate a programmatic access token for a service user without restricting that token to a specific role. Changing REQUIRE_ROLE_RESTRICTION_FOR_SERVICE_USERS from FALSE back to TRUE invalidates any programmatic access tokens for service users that were generated without the role restriction. Default value: TRUE | |
WORKLOAD_IDENTITY_POLICY = ( list_of_properties ) | optional | 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: For example:Copy code 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') ); |
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.
| |
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_IDENTITY of type AWS, 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_IDENTITY of type AZURE, 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_IDENTITY of type OIDC, 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. | |
COMMENT = 'string_literal' | optional | Specifies a description of the policy. |
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.
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 | Required to execute a CREATE OR ALTER AUTHENTICATION POLICY statement for an existing authentication policy. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent 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.
See also
- ALTER AUTHENTICATION POLICY
- DESCRIBE AUTHENTICATION POLICY
- DROP AUTHENTICATION POLICY
- SHOW AUTHENTICATION POLICIES