Skip to content

Commit ad5809a

Browse files
SNOW-2231895: Add warning on using http in oauth (#2747)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 9d005ac commit ad5809a

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1111
- Ensured proper list conversion - the converter runs to_snowflake on all list elements.
1212
- Made the parameter `server_session_keep_alive` in `SnowflakeConnection` skip checking for pending async queries, providing faster connection close times especially when many async queries are executed.
1313
- Fix string representation of INTERVAL YEAR and INTERVAL MONTH types.
14+
- Log a warning when using http protocol for OAuth urls.
1415

1516
- v4.2.0(January 07,2026)
1617
- Added `SnowflakeCursor.stats` property to expose granular DML statistics (rows inserted, deleted, updated, and duplicates) for operations like CTAS where `rowcount` is insufficient.

src/snowflake/connector/auth/_oauth_base.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,27 @@ def _create_token_request_headers(self) -> dict[str, str]:
428428
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
429429
}
430430

431+
@staticmethod
432+
def _log_if_http_in_use(url: str) -> None:
433+
"""Log a warning if the URL uses insecure HTTP protocol.
434+
435+
Args:
436+
url: The URL to check for HTTP usage
437+
"""
438+
try:
439+
parsed_url = urllib.parse.urlparse(url)
440+
if parsed_url.scheme == "http":
441+
logger.warning(
442+
"OAuth URL uses insecure HTTP protocol: %s",
443+
SecretDetector.mask_secrets(url),
444+
)
445+
except Exception as e:
446+
logger.warning(
447+
"Cannot parse URL: %s. %s",
448+
SecretDetector.mask_secrets(url),
449+
e,
450+
)
451+
431452
@staticmethod
432453
def _resolve_proxy_url(
433454
connection: SnowflakeConnection, request_url: str

src/snowflake/connector/auth/oauth_code.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ def __init__(
7979
host,
8080
connection,
8181
)
82+
# Warn if HTTP is used for OAuth URLs
83+
if authentication_url:
84+
self._log_if_http_in_use(authentication_url)
85+
if token_request_url:
86+
self._log_if_http_in_use(token_request_url)
8287

8388
super().__init__(
8489
client_id=client_id,

src/snowflake/connector/auth/oauth_credentials.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def __init__(
3131
**kwargs,
3232
) -> None:
3333
self._validate_client_credentials_present(client_id, client_secret, connection)
34+
# Warn if HTTP is used for OAuth token request URL
35+
if token_request_url:
36+
self._log_if_http_in_use(token_request_url)
3437
super().__init__(
3538
client_id=client_id,
3639
client_secret=client_secret,

0 commit comments

Comments
 (0)