Skip to content

Commit 17fbd55

Browse files
committed
enable_broker_on_wsl
1 parent 56c8124 commit 17fbd55

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/azure-cli-core/azure/cli/core/_profile.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,23 +999,29 @@ def _create_identity_instance(cli_ctx, authority, tenant_id=None, client_id=None
999999
"""Lazily import and create Identity instance to avoid unnecessary imports."""
10001000
from .auth.identity import Identity
10011001
from .util import should_encrypt_token_cache
1002+
from .telemetry import set_broker_info
1003+
10021004
encrypt = should_encrypt_token_cache(cli_ctx)
10031005

10041006
# EXPERIMENTAL: Use core.use_msal_http_cache=False to turn off MSAL HTTP cache.
10051007
use_msal_http_cache = cli_ctx.config.getboolean('core', 'use_msal_http_cache', fallback=True)
10061008

10071009
# On Windows, use core.enable_broker_on_windows=false to disable broker (WAM) for authentication.
10081010
enable_broker_on_windows = cli_ctx.config.getboolean('core', 'enable_broker_on_windows', fallback=True)
1009-
from .telemetry import set_broker_info
10101011
set_broker_info(enable_broker_on_windows)
10111012

1013+
# On WSL, use core.enable_broker_on_wsl=true to use broker (WAM)
1014+
enable_broker_on_wsl = cli_ctx.config.getboolean('core', 'enable_broker_on_wsl', fallback=False)
1015+
set_broker_info(enable_broker_on_wsl)
1016+
10121017
# PREVIEW: In Azure Stack environment, use core.instance_discovery=false to disable MSAL's instance discovery.
10131018
instance_discovery = cli_ctx.config.getboolean('core', 'instance_discovery', True)
10141019

10151020
return Identity(authority, tenant_id=tenant_id, client_id=client_id,
10161021
encrypt=encrypt,
10171022
use_msal_http_cache=use_msal_http_cache,
10181023
enable_broker_on_windows=enable_broker_on_windows,
1024+
enable_broker_on_wsl=enable_broker_on_wsl,
10191025
instance_discovery=instance_discovery)
10201026

10211027

src/azure-cli-core/azure/cli/core/auth/identity.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class Identity: # pylint: disable=too-many-instance-attributes
5858
_service_principal_store_instance = None
5959

6060
def __init__(self, authority, tenant_id=None, client_id=None, encrypt=False, use_msal_http_cache=True,
61-
enable_broker_on_windows=None, instance_discovery=None):
61+
enable_broker_on_windows=None, enable_broker_on_wsl=None,
62+
instance_discovery=None):
6263
"""
6364
:param authority: Authentication authority endpoint. For example,
6465
- AAD: https://login.microsoftonline.com
@@ -74,6 +75,7 @@ def __init__(self, authority, tenant_id=None, client_id=None, encrypt=False, use
7475
self._encrypt = encrypt
7576
self._use_msal_http_cache = use_msal_http_cache
7677
self._enable_broker_on_windows = enable_broker_on_windows
78+
self._enable_broker_on_wsl = enable_broker_on_wsl
7779
self._instance_discovery = instance_discovery
7880

7981
# Build the authority in MSAL style
@@ -112,7 +114,10 @@ def _msal_app_kwargs(self):
112114
def _msal_public_app_kwargs(self):
113115
"""kwargs for creating PublicClientApplication."""
114116
# enable_broker_on_windows can only be used on PublicClientApplication.
115-
return {**self._msal_app_kwargs, "enable_broker_on_windows": self._enable_broker_on_windows}
117+
return {**self._msal_app_kwargs,
118+
"enable_broker_on_windows": self._enable_broker_on_windows,
119+
"enable_broker_on_wsl": self._enable_broker_on_wsl
120+
}
116121

117122
@property
118123
def _msal_app(self):

src/azure-cli-core/azure/cli/core/telemetry.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def __init__(self, correlation_id=None, application=None):
7676
self.user_agent = None
7777
# authentication-related
7878
self.enable_broker_on_windows = None
79+
self.enable_broker_on_wsl = None
7980
self.msal_telemetry = None
8081
self.login_experience_v2 = None
8182

@@ -232,6 +233,7 @@ def _get_azure_cli_properties(self):
232233
set_custom_properties(result, 'SecretNames', ','.join(self.secret_names or []))
233234
# authentication-related
234235
set_custom_properties(result, 'EnableBrokerOnWindows', str(self.enable_broker_on_windows))
236+
set_custom_properties(result, 'EnableBrokerOnWsl', str(self.enable_broker_on_wsl))
235237
set_custom_properties(result, 'MsalTelemetry', self.msal_telemetry)
236238
set_custom_properties(result, 'LoginExperienceV2', str(self.login_experience_v2))
237239

@@ -471,9 +473,10 @@ def set_region_identified(region_input, region_identified):
471473

472474

473475
@decorators.suppress_all_exceptions()
474-
def set_broker_info(enable_broker_on_windows):
476+
def set_broker_info(enable_broker_on_windows, enable_broker_on_wsl):
475477
# Log the value of `enable_broker_on_windows`
476478
_session.enable_broker_on_windows = enable_broker_on_windows
479+
_session.enable_broker_on_wsl = enable_broker_on_wsl
477480

478481

479482
@decorators.suppress_all_exceptions()

0 commit comments

Comments
 (0)