Skip to content

Commit 2d8a795

Browse files
Remove WIF autodetect and all its problems (error messages, issuer checks, explicit timeouts), support explicit client_id for Azure VMs (#2457)
1 parent c85e592 commit 2d8a795

File tree

6 files changed

+216
-331
lines changed

6 files changed

+216
-331
lines changed

src/snowflake/connector/connection.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,13 +1326,21 @@ def __open_connection(self):
13261326
)
13271327
elif self._authenticator == WORKLOAD_IDENTITY_AUTHENTICATOR:
13281328
self._check_experimental_authentication_flag()
1329-
# Standardize the provider enum.
1330-
if self._workload_identity_provider and isinstance(
1331-
self._workload_identity_provider, str
1332-
):
1329+
1330+
if isinstance(self._workload_identity_provider, str):
13331331
self._workload_identity_provider = AttestationProvider.from_string(
13341332
self._workload_identity_provider
13351333
)
1334+
if not self._workload_identity_provider:
1335+
Error.errorhandler_wrapper(
1336+
self,
1337+
None,
1338+
ProgrammingError,
1339+
{
1340+
"msg": f"workload_identity_provider must be set to one of {','.join(AttestationProvider.all_string_values())} when authenticator is WORKLOAD_IDENTITY.",
1341+
"errno": ER_INVALID_WIF_SETTINGS,
1342+
},
1343+
)
13361344
self.auth_class = AuthByWorkloadIdentity(
13371345
provider=self._workload_identity_provider,
13381346
token=self._token,
@@ -1487,7 +1495,10 @@ def __config(self, **kwargs):
14871495
self,
14881496
None,
14891497
ProgrammingError,
1490-
{"msg": "User is empty", "errno": ER_NO_USER},
1498+
{
1499+
"msg": f"User is empty, but it must be provided unless authenticator is one of {', '.join(empty_user_allowed_authenticators)}.",
1500+
"errno": ER_NO_USER,
1501+
},
14911502
)
14921503

14931504
if self._private_key or self._private_key_file:

0 commit comments

Comments
 (0)