Skip to content

Commit 451a60b

Browse files
Prepare for Workload Identity Federation (WIF) GA (#2368)
1 parent d0d9587 commit 451a60b

File tree

7 files changed

+4
-34
lines changed

7 files changed

+4
-34
lines changed

DESCRIPTION.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
88

99
# Release Notes
1010
- v3.16.1(TBD)
11+
- Added new authentication methods support for Workload Identity Federation (WIF).
12+
- Added the `WORKLOAD_IDENTITY` value for authenticator type.
13+
- Added the `workload_identity_provider` and `workload_identity_entra_resource` parameters.
1114
- Added in-band OCSP exception telemetry.
1215
- Added `APPLICATION_PATH` within `CLIENT_ENVIRONMENT` to distinguish between multiple scripts using the PythonConnector in the same environment.
1316
- Disabled token caching for OAuth Client Credentials authentication

ci/container/test_authentication.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export SNOWFLAKE_AUTH_TEST_PRIVATE_KEY_PATH=./.github/workflows/parameters/priva
1313
export SNOWFLAKE_AUTH_TEST_INVALID_PRIVATE_KEY_PATH=./.github/workflows/parameters/private/rsa_keys/rsa_key_invalid.p8
1414

1515
export SF_OCSP_TEST_MODE=true
16-
export SF_ENABLE_EXPERIMENTAL_AUTHENTICATION=true
1716
export RUN_AUTH_TESTS=true
1817
export AUTHENTICATION_TESTS_ENV="docker"
1918
export PYTHONPATH=$SOURCE_ROOT

ci/wif/test_wif.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
set -o pipefail
44

55
export SF_OCSP_TEST_MODE=true
6-
export SF_ENABLE_EXPERIMENTAL_AUTHENTICATION=true
76
export RUN_WIF_TESTS=true
87

98
/opt/python/cp39-cp39/bin/python -m pip install --break-system-packages -e .

src/snowflake/connector/connection.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
_CONNECTIVITY_ERR_MSG,
6060
_DOMAIN_NAME_MAP,
6161
_OAUTH_DEFAULT_SCOPE,
62-
ENV_VAR_EXPERIMENTAL_AUTHENTICATION,
6362
ENV_VAR_PARTNER,
6463
PARAMETER_AUTOCOMMIT,
6564
PARAMETER_CLIENT_PREFETCH_THREADS,
@@ -88,7 +87,6 @@
8887
from .direct_file_operation_utils import FileOperationParser, StreamDownloader
8988
from .errorcode import (
9089
ER_CONNECTION_IS_CLOSED,
91-
ER_EXPERIMENTAL_AUTHENTICATION_NOT_SUPPORTED,
9290
ER_FAILED_PROCESSING_PYFORMAT,
9391
ER_FAILED_PROCESSING_QMARK,
9492
ER_FAILED_TO_CONNECT_TO_DB,
@@ -1329,8 +1327,6 @@ def __open_connection(self):
13291327
self._token, self._external_session_id
13301328
)
13311329
elif self._authenticator == WORKLOAD_IDENTITY_AUTHENTICATOR:
1332-
self._check_experimental_authentication_flag()
1333-
13341330
if isinstance(self._workload_identity_provider, str):
13351331
self._workload_identity_provider = AttestationProvider.from_string(
13361332
self._workload_identity_provider
@@ -2293,18 +2289,6 @@ def is_valid(self) -> bool:
22932289
logger.debug("session could not be validated due to exception: %s", e)
22942290
return False
22952291

2296-
def _check_experimental_authentication_flag(self) -> None:
2297-
if os.getenv(ENV_VAR_EXPERIMENTAL_AUTHENTICATION, "false").lower() != "true":
2298-
Error.errorhandler_wrapper(
2299-
self,
2300-
None,
2301-
ProgrammingError,
2302-
{
2303-
"msg": f"Please set the '{ENV_VAR_EXPERIMENTAL_AUTHENTICATION}' environment variable true to use the '{self._authenticator}' authenticator.",
2304-
"errno": ER_EXPERIMENTAL_AUTHENTICATION_NOT_SUPPORTED,
2305-
},
2306-
)
2307-
23082292
@staticmethod
23092293
def _detect_application() -> None | str:
23102294
if ENV_VAR_PARTNER in os.environ.keys():

src/snowflake/connector/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ class IterUnit(Enum):
428428
# TODO: all env variables definitions should be here
429429
ENV_VAR_PARTNER = "SF_PARTNER"
430430
ENV_VAR_TEST_MODE = "SNOWFLAKE_TEST_MODE"
431-
ENV_VAR_EXPERIMENTAL_AUTHENTICATION = "SF_ENABLE_EXPERIMENTAL_AUTHENTICATION" # Needed to enable new strong auth features during the private preview.
432431

433432

434433
_DOMAIN_NAME_MAP = {_DEFAULT_HOSTNAME_TLD: "GLOBAL", _CHINA_HOSTNAME_TLD: "CHINA"}

src/snowflake/connector/errorcode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
ER_OAUTH_SERVER_TIMEOUT = 251016
3434
ER_INVALID_WIF_SETTINGS = 251017
3535
ER_WIF_CREDENTIALS_NOT_FOUND = 251018
36+
# not used but keep here to reserve errno
3637
ER_EXPERIMENTAL_AUTHENTICATION_NOT_SUPPORTED = 251019
3738
ER_NO_CLIENT_SECRET = 251020
3839

test/unit/test_connection.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -639,17 +639,6 @@ def test_cannot_set_dependent_params_without_wlid_authenticator(
639639
)
640640

641641

642-
def test_cannot_set_wlid_authenticator_without_env_variable(mock_post_requests):
643-
with pytest.raises(ProgrammingError) as excinfo:
644-
snowflake.connector.connect(
645-
account="account", authenticator="WORKLOAD_IDENTITY"
646-
)
647-
assert (
648-
"Please set the 'SF_ENABLE_EXPERIMENTAL_AUTHENTICATION' environment variable true to use the 'WORKLOAD_IDENTITY' authenticator"
649-
in str(excinfo.value)
650-
)
651-
652-
653642
@pytest.mark.parametrize(
654643
"provider_param",
655644
[
@@ -665,7 +654,6 @@ def test_workload_identity_provider_is_required_for_wif_authenticator(
665654
m.setattr(
666655
"snowflake.connector.SnowflakeConnection._authenticate", lambda *_: None
667656
)
668-
m.setenv("SF_ENABLE_EXPERIMENTAL_AUTHENTICATION", "true")
669657

670658
with pytest.raises(ProgrammingError) as excinfo:
671659
snowflake.connector.connect(
@@ -701,7 +689,6 @@ def test_connection_params_are_plumbed_into_authbyworkloadidentity(
701689
m.setattr(
702690
"snowflake.connector.SnowflakeConnection._authenticate", lambda *_: None
703691
)
704-
m.setenv("SF_ENABLE_EXPERIMENTAL_AUTHENTICATION", "true")
705692

706693
conn = snowflake.connector.connect(
707694
account="my_account_1",
@@ -743,7 +730,6 @@ def test_toml_connection_params_are_plumbed_into_authbyworkloadidentity(
743730
m.setattr(
744731
"snowflake.connector.SnowflakeConnection._authenticate", lambda *_: None
745732
)
746-
m.setenv("SF_ENABLE_EXPERIMENTAL_AUTHENTICATION", "true")
747733

748734
conn = snowflake.connector.connect(connections_file_path=connections_file)
749735
assert conn.auth_class.provider == AttestationProvider.OIDC
@@ -762,7 +748,6 @@ def test_single_use_refresh_tokens_option_is_plumbed_into_authbyauthcode(
762748
m.setattr(
763749
"snowflake.connector.SnowflakeConnection._authenticate", lambda *_: None
764750
)
765-
m.setenv("SF_ENABLE_EXPERIMENTAL_AUTHENTICATION", "true")
766751

767752
conn = snowflake.connector.connect(
768753
account="my_account_1",

0 commit comments

Comments
 (0)