Skip to content

Commit 4b9dba7

Browse files
authored
Snowflake connectors: use PATs for authentication instead of passwords; use service users over human users (#728)
1 parent cabadfa commit 4b9dba7

File tree

12 files changed

+146
-12
lines changed

12 files changed

+146
-12
lines changed

snippets/destination_connectors/snowflake.sh.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ unstructured \
1515
snowflake \
1616
--account $SNOWFLAKE_ACCOUNT \
1717
--user $SNOWFLAKE_USER \
18-
--password $SNOWFLAKE_PASSWORD \
18+
--password $SNOWFLAKE_PROGRAMMATIC_ACCESS_TOKEN \
1919
--role $SNOWFLAKE_ROLE \
2020
--host $SNOWFLAKE_HOST \
2121
--port $SNOWFLAKE_PORT \

snippets/destination_connectors/snowflake.v2.py.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if __name__ == "__main__":
4141
embedder_config=EmbedderConfig(embedding_provider="huggingface"),
4242
destination_connection_config=SnowflakeConnectionConfig(
4343
access_config=SnowflakeAccessConfig(
44-
password=os.getenv("SNOWFLAKE_PASSWORD")
44+
password=os.getenv("SNOWFLAKE_PROGRAMMATIC_ACCESS_TOKEN")
4545
),
4646
account=os.getenv("SNOWFLAKE_ACCOUNT"),
4747
user=os.getenv("SNOWFLAKE_USER"),

snippets/destination_connectors/snowflake_rest_create.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ curl --request 'POST' --location \
1616
"database": "<database>",
1717
"schema": "<schema>",
1818
"role": "<role>",
19-
"password": "<password>",
19+
"password": "<programmatic-access-token>",
2020
"record_id_key": "<record-id-key>",
2121
"table_name": "<table_name>",
2222
"batch_size": <batch-size>

snippets/destination_connectors/snowflake_sdk.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ with UnstructuredClient(api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")) as clien
1919
"database": "<database>",
2020
"schema": "<schema>",
2121
"role": "<role>",
22-
"password": "<password>",
22+
"password": "<programmatic-access-token>",
2323
"record_id_key": "<record-id-key>",
2424
"table_name": "<table_name>",
2525
"batch_size": <batch-size>

snippets/general-shared-text/snowflake-api-placeholders.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
- `<account>` (_required_): The target Snowflake account's identifier.
33
- `<role>` (_required_): The name of the Snowflake role that the user belongs to. This role must have the appropriate access to the target Snowflake warehouse, database, schema, and table.
44
- `<user>` (_required_): The target Snowflake user's login name (not their username).
5-
- `<password>` (_required_): The user's password.
5+
- `<programmatic-access-token>` (_required_): The user's programmatic access token (PAT).
6+
7+
<Note>
8+
Specifying a password is no longer recommended, as passwords are being deprecated by Snowflake. Use a PAT instead.
9+
</Note>
10+
611
- `<host>` (_required_): The hostname of the target Snowflake warehouse.
712
- `<port>` (_required_): The warehouse's port number. The default is `443` if not otherwise specified.
813
- `<database>` (_required_): The name of the target Snowflake database.

snippets/general-shared-text/snowflake-cli-api.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ These environment variables:
1212

1313
- `SNOWFLAKE_ACCOUNT` - The ID of the target Snowflake account, represented by `--account` (CLI) or `account` (Python).
1414
- `SNOWFLAKE_USER` - The name of the target Snowflake user, represented by `--user` (CLI) or `user` (Python).
15-
- `SNOWFLAKE_PASSWORD` - The user's password, represented by `--password` (CLI) or `password` (Python).
15+
- `SNOWFLAKE_PROGRAMMATIC_ACCESS_TOKEN` - The user's programmatic access token (PAT), represented by `--password` (CLI) or `password` (Python).
16+
17+
<Note>
18+
Specifying a password is no longer recommended, as passwords are being deprecated by Snowflake. Use a PAT instead.
19+
</Note>
20+
1621
- `SNOWFLAKE_ROLE` - The target role for the user, represented by `--role` (CLI) or `role` (Python).
1722
- `SNOWFLAKE_HOST` - The hostname for the target Snowflake warehouse, represented by `--host` (CLI) or `host` (Python).
1823
- `SNOWFLAKE_PORT` - The warehouse's port number, represented by `--port` (CLI) or `port` (Python). The default is `443` if not otherwise specified.

snippets/general-shared-text/snowflake-platform.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ Fill in the following fields:
44
- **Account ID** (_required_): The target Snowflake account's identifier.
55
- **Role** (_required_): The name of the Snowflake role that the user belongs to. This role must have the appropriate access to the target Snowflake warehouse, database, schema, and table.
66
- **User** (_required_): The target Snowflake user's login name (not their username).
7-
- **Password** (_required_): The user's password.
7+
- **Password** (_required_): The user's programmatic access token (PAT).
8+
9+
<Note>
10+
Specifying a password is no longer recommended, as passwords are being deprecated by Snowflake. Use a PAT instead.
11+
</Note>
12+
813
- **Host** (_required_): The hostname of the target Snowflake warehouse.
914
- **Port** (_required_): The warehouse's port number. The default is `443` if not otherwise specified.
1015
- **Database** (_required_): The name of the target Snowflake database.

snippets/general-shared-text/snowflake.mdx

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,126 @@
2222
SELECT CURRENT_ORGANIZATION_NAME() || '-' || CURRENT_ACCOUNT_NAME() AS "Account Identifier"
2323
```
2424

25-
- The Snowflake [user's login name (not its username) and its password](https://docs.snowflake.com/user-guide/admin-user-management#creating-users) in the account.
25+
- A Snowflake user, which can be a service user (recommended) or a human user.
26+
27+
To create a service user (recommended):
28+
29+
1. Log in to [Snowsight](https://docs.snowflake.com/user-guide/ui-snowsight-homepage) with your Snowflake account.
30+
2. In Snowsight, on the navigation menu, click **Projects > Worksheets**.
31+
3. Click the **+** button to create a SQL worksheet.
32+
4. In the worksheet, enter the following Snowflake query to create a service user, replacing the following placeholders:
33+
34+
- Replace `<service-user-name>` with some name for the service user.
35+
- Replace `<default-role-name>` with the name of any default role for the service user to use.
36+
37+
```sql
38+
CREATE USER <service-user-name>
39+
DEFAULT_ROLE = "<default-role-name>"
40+
TYPE = SERVICE
41+
```
42+
43+
5. Click the arrow icon to run the worksheet, which creates the service user.
44+
45+
To create a human user:
46+
47+
1. Log in to [Snowsight](https://docs.snowflake.com/user-guide/ui-snowsight-homepage) with your Snowflake account.
48+
2. In Snowsight, on the navigation menu, click **Admin > Users & roles**.
49+
3. Click the **Users** tab.
50+
4. Click **+ User**.
51+
5. Follow the on-screen guidance to specify the user's settings.
52+
6. Click **Create User**.
53+
54+
- The Snowflake [user's login name (not username)](https://docs.snowflake.com/user-guide/admin-user-management#creating-users) in the account, and
55+
a programmatic access token (PAT) for the Snowflake user.
56+
57+
<iframe
58+
width="560"
59+
height="315"
60+
src="https://www.youtube.com/embed/sFLPGVe4VBM"
61+
title="YouTube video player"
62+
frameborder="0"
63+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
64+
allowfullscreen
65+
></iframe>
66+
67+
To view the login name for a user:
68+
69+
1. Log in to [Snowsight](https://docs.snowflake.com/user-guide/ui-snowsight-homepage) with your Snowflake account.
70+
2. In Snowsight, on the navigation menu, click **Admin > Users & Roles**.
71+
3. On the **Users** tab, in the list of available users, click the name of the target user.
72+
4. In the **About** tile, note the **Login Name** for the user.
73+
74+
Alternatively, the following Snowflake query returns information about the user with the username of `<my-user>`, including their `login_name` value representing their login name:
75+
76+
```text
77+
SHOW USERS LIKE '<my-user>';
78+
```
79+
80+
To create a programmatic access token (PAT) for a user:
81+
82+
1. Log in to [Snowsight](https://docs.snowflake.com/user-guide/ui-snowsight-homepage) with your Snowflake account.
83+
2. In Snowsight, on the navigation menu, click **Admin > Users & Roles**.
84+
3. On the **Users** tab, in the list of available users, click the name of the target user.
85+
4. In the **Programmatic access tokens** tile, click the **Generate new token** button.
86+
5. Follow the on-screen guidance to specify the PAT's settings.
87+
88+
<Warning>
89+
You must set an expiration date for the PAT. This expiration date can be as soon as one day after the PAT is created or up to one year or even later.
90+
Once this PAT expires, the connector will stop working.
91+
To make sure that your connector continues to work, before your current PAT expires, you must follow this procedure again to generate a new PAT and
92+
update your connector's settings with your new PAT's value.
93+
94+
Unstructured does not notify you when a PAT is about to expire or has already expired.
95+
You are responsible for tracking your PATs' expiration dates and taking corrective action before they expire.
96+
</Warning>
97+
98+
6. Click **Generate**.
99+
7. Copy the generated PAT's value to a secure location, as you will not be able to access it again. If you lose this PAT's value,
100+
you will need to repeat this procedure to generate a new, replacement one.
101+
102+
The PAT will not work unless the Snowflake account also has a valid
103+
[network rule](https://docs.snowflake.com/en/user-guide/network-rules) along with a valid
104+
[network policy](https://docs.snowflake.com/en/user-guide/network-policies) attached to that rule.
105+
The network rule must also be activated on the Snowflake account to begin taking effect.
106+
107+
To create a valid network rule:
108+
109+
1. Log in to [Snowsight](https://docs.snowflake.com/user-guide/ui-snowsight-homepage) with your Snowflake account.
110+
2. In Snowsight, on the navigation menu, click **Admin > Security > Network Rules**.
111+
3. Click **+ Network Rule**.
112+
4. Enter some name for the network rule.
113+
5. For **Type**, select **IPv4**.
114+
6. For **Mode**, select **Ingress**.
115+
7. For **Identifiers**, next to the magnifying glass icon, enter `0.0.0.0/0`, and then press **Enter**.
116+
117+
<Note>
118+
The `0.0.0.0/0` value allows all IP addresses to access the Snowflake account.
119+
You can specify a more specific IP address range if you prefer. However, this more specific IP address range
120+
will apply to all users, including the user for which you created the PAT.
121+
</Note>
122+
123+
8. Click **Create Network Rule**.
124+
125+
To create a valid network policy, attaching the preceding network rule to this policy at the same time:
126+
127+
1. Log in to [Snowsight](https://docs.snowflake.com/user-guide/ui-snowsight-homepage) with your Snowflake account.
128+
2. In Snowsight, on the navigation menu, click **Admin > Security > Network Policies**.
129+
3. Click **+ Network Policy**.
130+
4. Enter some name for the network policy.
131+
5. Make sure **Allowed** is selected.
132+
5. In the **Select rule** drop-down list, select the precedingnetwork rule to attach to this network policy.
133+
6. Click **Create Network Policy**.
134+
135+
To activate the network rule in the account:
136+
137+
1. Log in to [Snowsight](https://docs.snowflake.com/user-guide/ui-snowsight-homepage) with your Snowflake account.
138+
2. In Snowsight, on the navigation menu, click **Admin > Security > Network Policies**.
139+
3. Click the name of the precedingnetwork policy to activate.
140+
4. In the policy's side panel, click the ellipsis (three dots) icon, and then click **Activate On Account**.
141+
5. Click **Activate policy**.
142+
143+
- (No longer recommended, as passwords are being deprecated by Snowflake&mdash;use PATs instead) The Snowflake [user's login name (not username) and the user's password](https://docs.snowflake.com/user-guide/admin-user-management#creating-users) in the account.
144+
This user must be a human user. Passwords are not supported for service users.
26145

27146
<iframe
28147
width="560"

snippets/source_connectors/snowflake.sh.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ unstructured \
55
snowflake \
66
--account $SNOWFLAKE_ACCOUNT \
77
--user $SNOWFLAKE_USER \
8-
--password $SNOWFLAKE_PASSWORD \
8+
--password $SNOWFLAKE_PROGRAMMATIC_ACCESS_TOKEN \
99
--role $SNOWFLAKE_ROLE \
1010
--host $SNOWFLAKE_HOST \
1111
--port $SNOWFLAKE_PORT \

snippets/source_connectors/snowflake.v2.py.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if __name__ == "__main__":
2828
downloader_config=SnowflakeDownloaderConfig(download_dir=os.getenv("LOCAL_FILE_DOWNLOAD_DIR")),
2929
source_connection_config=SnowflakeConnectionConfig(
3030
access_config=SnowflakeAccessConfig(
31-
password=os.getenv("SNOWFLAKE_PASSWORD")
31+
password=os.getenv("SNOWFLAKE_PROGRAMMATIC_ACCESS_TOKEN")
3232
),
3333
account=os.getenv("SNOWFLAKE_ACCOUNT"),
3434
user=os.getenv("SNOWFLAKE_USER"),

0 commit comments

Comments
 (0)