Skip to content

Commit 4bf2a4e

Browse files
authored
FIX: Interactive on Windows (#142)
### ADO Work Item Reference <!-- Insert your ADO Work Item ID below (e.g. AB#37452) --> > [AB#38007](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/38007) ------------------------------------------------------------------- ### Summary This pull request includes a small change to the `process_auth_parameters` function in `mssql_python/auth.py`. The change adjusts how the `auth_type` is handled for interactive authentication on Windows, ensuring compatibility with native handling of AADInteractive. --------- Co-authored-by: Jahnvi Thakkar <jathakkar@microsoft.com>
1 parent 919c230 commit 4bf2a4e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

mssql_python/auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ def process_auth_parameters(parameters: list) -> Tuple[list, Optional[str]]:
8484
if key_lower == "authentication":
8585
# Check for supported authentication types and set auth_type accordingly
8686
if value_lower == AuthType.INTERACTIVE.value:
87+
auth_type = "interactive"
8788
# Interactive authentication (browser-based); only append parameter for non-Windows
8889
if platform.system().lower() == "windows":
89-
continue # Skip adding this parameter for Windows
90-
auth_type = "interactive"
90+
auth_type = None # Let Windows handle AADInteractive natively
91+
9192
elif value_lower == AuthType.DEVICE_CODE.value:
9293
# Device code authentication (for devices without browser)
9394
auth_type = "devicecode"

tests/test_008_auth.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,23 @@ def test_interactive_auth_windows(self, monkeypatch):
137137
monkeypatch.setattr(platform, "system", lambda: "Windows")
138138
params = ["Authentication=ActiveDirectoryInteractive", "Server=test"]
139139
modified_params, auth_type = process_auth_parameters(params)
140-
assert "Authentication=ActiveDirectoryInteractive" not in modified_params
140+
assert "Authentication=ActiveDirectoryInteractive" in modified_params
141141
assert auth_type == None
142142

143143
def test_interactive_auth_non_windows(self, monkeypatch):
144144
monkeypatch.setattr(platform, "system", lambda: "Darwin")
145145
params = ["Authentication=ActiveDirectoryInteractive", "Server=test"]
146-
modified_params, auth_type = process_auth_parameters(params)
147-
assert "Authentication=ActiveDirectoryInteractive" in modified_params
146+
_, auth_type = process_auth_parameters(params)
148147
assert auth_type == "interactive"
149148

150149
def test_device_code_auth(self):
151150
params = ["Authentication=ActiveDirectoryDeviceCode", "Server=test"]
152-
modified_params, auth_type = process_auth_parameters(params)
151+
_, auth_type = process_auth_parameters(params)
153152
assert auth_type == "devicecode"
154153

155154
def test_default_auth(self):
156155
params = ["Authentication=ActiveDirectoryDefault", "Server=test"]
157-
modified_params, auth_type = process_auth_parameters(params)
156+
_, auth_type = process_auth_parameters(params)
158157
assert auth_type == "default"
159158

160159
class TestRemoveSensitiveParams:

0 commit comments

Comments
 (0)