Skip to content

Commit 8d8afbb

Browse files
SNOW-2264068 auth OIDC updated (#2541) (#2552)
* SNOW-2264068 auth OIDC updated (#2541) * SNOW-2176180: renamed setup to create-user, dropped list in snow auth oidc * SNOW-2176180: update integration tests * SNOW-2176180: support for workload identity provider in snow connection add * SNOW-2176180: fix typos * SNOW-2176180: fix typos 2 * SNOW-2176180: renamed federated-user to user-name and RELEASE-NOTES update * SNOW-2176180: remove redundant check * SNOW-2176180: pre release connector test * SNOW-2176180: restore dependencies * SNOW-2176180: add connection option workload-identity-provider * SNOW-2176180: do not log to console oidc auto detection * SNOW-2176180: use oidc for auto detection only if provider is OIDC * SNOW-2176180: update the value checks * SNOW-2176180: update test snapshots * SNOW-2176180: bump connetor python to 3.17 * SNOW-2176180: make workload-identity-provider short verion uppercase W * SNOW-2176180: cr fixes - p1 * SNOW-2176180: bump connector to 3.17.1 * SNOW-2176180: snaptshot updates * SNOW-2176180: debug * SNOW-2176180: debug2 * SNOW-2176180: drop create-user and delete commands from snow auth oidc * SNOW-2176180: fix connector updated error messages * SNOW-2176180: CR cleanups * SNOW-2176180: CR remove comments * SNOW-2176180: CR fix doc string * chore: [NO-SNOW] update release notes for 3.10.1 (#2543) * Bump version to v3.11.0-rc1 --------- Co-authored-by: Jakub Wilkowski <[email protected]>
1 parent 49a7545 commit 8d8afbb

26 files changed

+902
-852
lines changed

RELEASE-NOTES.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@
3030
## New additions
3131
* Add `snow connection remove` command
3232
* Added support for `runtime_environment_version` field in notebook entity configuration, allowing specification of runtime environment version for containerized notebooks.
33-
* Added `snow auth workload-identity` command group for managing workload identity federation authentication:
34-
* `snow auth workload-identity setup` - Creates federated users with OIDC authentication configuration
35-
* `snow auth workload-identity delete` - Removes existing federated users
36-
* `snow auth workload-identity read-token` - Reads and displays OIDC tokens from CI/CD environments
37-
* `snow auth workload-identity list` - Lists all users with workload identity federation enabled
33+
* Added `snow auth oidc` command group for managing workload identity federation authentication:
34+
* `snow auth oidc read-token` - Reads and displays OIDC tokens from CI/CD environments
3835
* Supports GitHub Actions OIDC provider for passwordless authentication in CI/CD pipelines
3936

4037
## Fixes and improvements
38+
39+
40+
# v3.10.1
41+
42+
## Deprecations
43+
44+
## New additions
45+
46+
## Fixes and improvements
4147
* Fixed DBT deploy command to properly handle fully qualified names
4248
* Fixed DBT deploy command to properly handle local directories with dots in names
4349

pylock.toml

Lines changed: 27 additions & 27 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies = [
4040
"requirements-parser==0.13.0",
4141
"rich==14.0.0",
4242
"setuptools==80.8.0",
43-
"snowflake-connector-python[secure-local-storage]==3.16.0",
43+
"snowflake-connector-python[secure-local-storage]==3.17.1",
4444
'snowflake-snowpark-python==1.33.0;python_version < "3.12"',
4545
"snowflake.core==1.6.0",
4646
"tomlkit==0.13.3",

snyk/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ setuptools==80.8.0
5454
shellingham==1.5.4
5555
six==1.17.0
5656
smmap==5.0.2
57-
snowflake-connector-python==3.16.0
57+
snowflake-connector-python==3.17.1
5858
snowflake-core==1.6.0
5959
snowflake-snowpark-python==1.33.0 ; python_full_version < '3.12'
6060
sortedcontainers==2.4.0

src/snowflake/cli/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from enum import Enum, unique
1818

19-
VERSION = "3.11.0rc0"
19+
VERSION = "3.11.0rc1"
2020

2121

2222
@unique

src/snowflake/cli/_app/auth/oidc_providers.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,30 +364,28 @@ def auto_detect_oidc_provider() -> OidcTokenProvider:
364364
return available[0]
365365
case (0, providers) if providers:
366366
# No providers available but some are registered
367-
logger.warning("No OIDC provider detected in current environment")
368367
providers_list = ", ".join(providers)
369-
error_msg = (
368+
msg = (
370369
"No OIDC provider detected in current environment. "
371370
"Available providers: %s. "
372371
"Use --type <provider> to specify a provider explicitly."
373372
) % providers_list
374-
logger.error(error_msg)
375-
raise OidcProviderAutoDetectionError(error_msg)
373+
logger.info(msg)
374+
raise OidcProviderAutoDetectionError(msg)
376375
case (0, _):
377376
# No providers available and none are registered
378-
logger.warning("No OIDC provider detected in current environment")
379-
error_msg = "No OIDC providers are registered."
380-
logger.error(error_msg)
381-
raise OidcProviderAutoDetectionError(error_msg)
377+
msg = "No OIDC providers are registered."
378+
logger.info(msg)
379+
raise OidcProviderAutoDetectionError(msg)
382380
case _:
383381
# Multiple providers available - raise error
384382
providers_list = ", ".join(available_names)
385-
error_msg = (
383+
msg = (
386384
"Multiple OIDC providers detected: %s. "
387385
"Please specify which provider to use with --type <provider>."
388386
) % providers_list
389-
logger.error(error_msg)
390-
raise OidcProviderAutoDetectionError(error_msg)
387+
logger.info(msg)
388+
raise OidcProviderAutoDetectionError(msg)
391389

392390
# This line should never be reached, but helps mypy understand all paths are covered
393391
raise OidcProviderAutoDetectionError(

src/snowflake/cli/_app/snow_connector.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from snowflake.cli.api.secret import SecretType
4646
from snowflake.cli.api.secure_path import SecurePath
4747
from snowflake.connector import SnowflakeConnection
48+
from snowflake.connector.auth.workload_identity import ApiFederatedAuthenticationType
4849
from snowflake.connector.errors import DatabaseError, ForbiddenError
4950

5051
log = logging.getLogger(__name__)
@@ -59,6 +60,7 @@
5960
"user",
6061
"password",
6162
"authenticator",
63+
"workload_identity_provider",
6264
"private_key_file",
6365
"private_key_path",
6466
"private_key_raw",
@@ -158,8 +160,12 @@ def connect_to_snowflake(
158160
if connection_parameters.get("authenticator") == "username_password_mfa":
159161
connection_parameters["client_request_mfa_token"] = True
160162

161-
# Handle WORKLOAD_IDENTITY authenticator (OIDC federated authentication)
162-
if connection_parameters.get("authenticator") == AUTHENTICATOR_WORKLOAD_IDENTITY:
163+
# Handle WORKLOAD_IDENTITY authenticator (OIDC authentication)
164+
if (
165+
connection_parameters.get("authenticator") == AUTHENTICATOR_WORKLOAD_IDENTITY
166+
and connection_parameters.get("workload_identity_provider")
167+
== ApiFederatedAuthenticationType.OIDC.value
168+
):
163169
_maybe_update_oidc_token(connection_parameters)
164170

165171
if enable_diag:

src/snowflake/cli/_plugins/auth/oidc/commands.py

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,18 @@
1414

1515
import typer
1616
from snowflake.cli._app.auth.oidc_providers import (
17-
OidcProviderType,
1817
OidcProviderTypeWithAuto,
1918
)
2019
from snowflake.cli._plugins.auth.oidc.manager import OidcManager
2120
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
22-
from snowflake.cli.api.output.types import MessageResult, QueryResult
21+
from snowflake.cli.api.output.types import MessageResult
2322

2423
app = SnowTyperFactory(
2524
name="oidc",
26-
help="Manages OIDC federated authentication.",
25+
help="Manages OIDC authentication.",
2726
)
2827

2928

30-
FederatedUserOption = typer.Option(
31-
...,
32-
"--federated-user",
33-
show_default=False,
34-
help="Name for the federated user to create",
35-
prompt="Enter federated user name",
36-
)
37-
38-
FederatedUserArgument = typer.Argument(
39-
...,
40-
help="Name for the federated user to drop",
41-
show_default=False,
42-
)
43-
44-
SubjectOption = typer.Option(
45-
...,
46-
"--subject",
47-
show_default=False,
48-
help="OIDC subject string",
49-
prompt="Enter OIDC subject string",
50-
)
51-
52-
DefaultRoleOption = typer.Option(
53-
...,
54-
"--default-role",
55-
show_default=False,
56-
help="Default role to assign to the federated user",
57-
prompt="Enter default role",
58-
)
59-
60-
ProviderTypeOption = typer.Option(
61-
...,
62-
"--type",
63-
help=f"Type of OIDC provider to use",
64-
prompt="Enter OIDC provider type",
65-
show_default=False,
66-
)
67-
6829
AutoProviderTypeOption = typer.Option(
6930
OidcProviderTypeWithAuto.AUTO.value,
7031
"--type",
@@ -73,39 +34,6 @@
7334
)
7435

7536

76-
@app.command("setup", requires_connection=True)
77-
def setup(
78-
_type: OidcProviderType = ProviderTypeOption,
79-
federated_user: str = FederatedUserOption,
80-
subject: str = SubjectOption,
81-
default_role: str = DefaultRoleOption,
82-
**options,
83-
):
84-
"""
85-
Sets up OIDC federated authentication.
86-
Creates a federated user with the specified configuration.
87-
"""
88-
result = OidcManager().setup(
89-
user=federated_user,
90-
subject=subject,
91-
default_role=default_role,
92-
provider_type=_type,
93-
)
94-
return MessageResult(result)
95-
96-
97-
@app.command("delete", requires_connection=True)
98-
def delete(
99-
federated_user=FederatedUserArgument,
100-
**options,
101-
):
102-
"""
103-
Deletes a federated user.
104-
"""
105-
result = OidcManager().delete(user=federated_user)
106-
return MessageResult(result)
107-
108-
10937
@app.command("read-token", requires_connection=False)
11038
def read_token(
11139
_type: OidcProviderTypeWithAuto = AutoProviderTypeOption,
@@ -117,14 +45,3 @@ def read_token(
11745
"""
11846
result = OidcManager().read_token(provider_type=_type)
11947
return MessageResult(result)
120-
121-
122-
@app.command("list", requires_connection=True)
123-
def list_users(
124-
**options,
125-
):
126-
"""
127-
Lists users with OIDC federated authentication enabled.
128-
"""
129-
result = OidcManager().get_users_list()
130-
return QueryResult(result)

0 commit comments

Comments
 (0)