Skip to content

Commit 28b45a3

Browse files
committed
Remove automatic msa-pt for Azure CLI and Visual Studio
1 parent f41d546 commit 28b45a3

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

msal/application.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,17 @@ def acquire_token_interactive(
17661766
- A dict containing an "error" key, when token refresh failed.
17671767
"""
17681768
data = kwargs.pop("data", {})
1769+
enable_msa_passthrough = kwargs.pop( # MUST remove it from kwargs
1770+
"enable_msa_passthrough", # Keep it as a hidden param, for now.
1771+
# OPTIONAL. MSA-Passthrough is a legacy configuration,
1772+
# needed by a small amount of Microsoft first-party apps,
1773+
# which would login MSA accounts via ".../organizations" authority.
1774+
# If you app belongs to this category, AND you are enabling broker,
1775+
# you would want to enable this flag. Default value is False.
1776+
# More background of MSA-PT is available from this internal docs:
1777+
# https://microsoft.sharepoint.com/:w:/t/Identity-DevEx/EatIUauX3c9Ctw1l7AQ6iM8B5CeBZxc58eoQCE0IuZ0VFw?e=tgc3jP&CID=39c853be-76ea-79d7-ee73-f1b2706ede05
1778+
False
1779+
) and data.get("token_type") != "ssh-cert" # Work around a known issue as of PyMsalRuntime 0.8
17691780
self._validate_ssh_cert_input_data(data)
17701781
if not on_before_launching_ui:
17711782
on_before_launching_ui = lambda **kwargs: None
@@ -1786,21 +1797,6 @@ def acquire_token_interactive(
17861797
logger.warning(
17871798
"Ignoring parameter extra_scopes_to_consent, "
17881799
"which is not supported by broker")
1789-
enable_msa_passthrough = kwargs.pop(
1790-
"enable_msa_passthrough", # Keep it as a hidden param, for now.
1791-
# OPTIONAL. MSA-Passthrough is a legacy configuration,
1792-
# needed by a small amount of Microsoft first-party apps,
1793-
# which would login MSA accounts via ".../organizations" authority.
1794-
# If you app belongs to this category, AND you are enabling broker,
1795-
# you would want to enable this flag. Default value is equivalent to False.
1796-
self.client_id in [
1797-
# Experimental: Automatically enable MSA-PT mode for known MSA-PT apps
1798-
# More background of MSA-PT is available from this internal docs:
1799-
# https://microsoft.sharepoint.com/:w:/t/Identity-DevEx/EatIUauX3c9Ctw1l7AQ6iM8B5CeBZxc58eoQCE0IuZ0VFw?e=tgc3jP&CID=39c853be-76ea-79d7-ee73-f1b2706ede05
1800-
"04b07795-8ddb-461a-bbee-02f9e1bf7b46", # Azure CLI
1801-
"04f0c124-f2bc-4f59-8241-bf6df9866bbd", # Visual Studio
1802-
] and data.get("token_type") != "ssh-cert" # Work around a known issue as of PyMsalRuntime 0.8
1803-
)
18041800
return self._acquire_token_interactive_via_broker(
18051801
scopes,
18061802
parent_window_handle,

tests/msaltest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import getpass, logging, pprint, sys, msal
22

33

4+
AZURE_CLI = "04b07795-8ddb-461a-bbee-02f9e1bf7b46"
5+
VISUAL_STUDIO = "04f0c124-f2bc-4f59-8241-bf6df9866bbd"
6+
47
def _input_boolean(message):
58
return input(
69
"{} (N/n/F/f or empty means False, otherwise it is True): ".format(message)
@@ -81,6 +84,9 @@ def _acquire_token_interactive(app, scopes, data=None):
8184
result = app.acquire_token_interactive(
8285
scopes,
8386
parent_window_handle=app.CONSOLE_WINDOW_HANDLE, # This test app is a console app
87+
enable_msa_passthrough=app.client_id in [ # Apps are expected to set this right
88+
AZURE_CLI, VISUAL_STUDIO,
89+
], # Here this test app mimics the setting for some known MSA-PT apps
8490
prompt=prompt, login_hint=login_hint, data=data or {})
8591
if login_hint and "id_token_claims" in result:
8692
signed_in_user = result.get("id_token_claims", {}).get("preferred_username")
@@ -142,8 +148,8 @@ def exit(app):
142148
def main():
143149
print("Welcome to the Msal Python Console Test App, committed at 2022-5-2\n")
144150
chosen_app = _select_options([
145-
{"client_id": "04b07795-8ddb-461a-bbee-02f9e1bf7b46", "name": "Azure CLI (Correctly configured for MSA-PT)"},
146-
{"client_id": "04f0c124-f2bc-4f59-8241-bf6df9866bbd", "name": "Visual Studio (Correctly configured for MSA-PT)"},
151+
{"client_id": AZURE_CLI, "name": "Azure CLI (Correctly configured for MSA-PT)"},
152+
{"client_id": VISUAL_STUDIO, "name": "Visual Studio (Correctly configured for MSA-PT)"},
147153
{"client_id": "95de633a-083e-42f5-b444-a4295d8e9314", "name": "Whiteboard Services (Non MSA-PT app. Accepts AAD & MSA accounts.)"},
148154
],
149155
option_renderer=lambda a: a["name"],

0 commit comments

Comments
 (0)