Skip to content

Commit

Permalink
enable_broker_on_windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasli committed Dec 21, 2023
1 parent 3ed4cef commit 45d1a69
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
9 changes: 5 additions & 4 deletions src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,13 +856,14 @@ def _create_identity_instance(cli_ctx, *args, **kwargs):
# EXPERIMENTAL: Use core.use_msal_http_cache=False to turn off MSAL HTTP cache.
use_msal_http_cache = cli_ctx.config.getboolean('core', 'use_msal_http_cache', fallback=True)

# PREVIEW: On Windows, use core.allow_broker=true to use broker (WAM) for authentication.
allow_broker = cli_ctx.config.getboolean('core', 'allow_broker', fallback=False)
# On Windows, use core.enable_broker_on_windows=true to use broker (WAM) for authentication.
enable_broker_on_windows = cli_ctx.config.getboolean('core', 'enable_broker_on_windows', fallback=False)
from .telemetry import set_broker_info
set_broker_info(allow_broker=allow_broker)
set_broker_info(enable_broker_on_windows=enable_broker_on_windows)

# PREVIEW: In Azure Stack environment, use core.instance_discovery=false to disable MSAL's instance discovery.
instance_discovery = cli_ctx.config.getboolean('core', 'instance_discovery', True)

return Identity(*args, encrypt=encrypt, use_msal_http_cache=use_msal_http_cache, allow_broker=allow_broker,
return Identity(*args, encrypt=encrypt, use_msal_http_cache=use_msal_http_cache,
enable_broker_on_windows=enable_broker_on_windows,
instance_discovery=instance_discovery, **kwargs)
8 changes: 4 additions & 4 deletions src/azure-cli-core/azure/cli/core/auth/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Identity: # pylint: disable=too-many-instance-attributes
_service_principal_store_instance = None

def __init__(self, authority, tenant_id=None, client_id=None, encrypt=False, use_msal_http_cache=True,
allow_broker=None, instance_discovery=None):
enable_broker_on_windows=None, instance_discovery=None):
"""
:param authority: Authentication authority endpoint. For example,
- AAD: https://login.microsoftonline.com
Expand All @@ -69,7 +69,7 @@ def __init__(self, authority, tenant_id=None, client_id=None, encrypt=False, use
self.client_id = client_id or AZURE_CLI_CLIENT_ID
self._encrypt = encrypt
self._use_msal_http_cache = use_msal_http_cache
self._allow_broker = allow_broker
self._enable_broker_on_windows = enable_broker_on_windows
self._instance_discovery = instance_discovery

# Build the authority in MSAL style
Expand Down Expand Up @@ -107,8 +107,8 @@ def _msal_app_kwargs(self):
@property
def _msal_public_app_kwargs(self):
"""kwargs for creating PublicClientApplication."""
# allow_broker can only be used on PublicClientApplication.
return {**self._msal_app_kwargs, "allow_broker": self._allow_broker}
# enable_broker_on_windows can only be used on PublicClientApplication.
return {**self._msal_app_kwargs, "enable_broker_on_windows": self._enable_broker_on_windows}

@property
def _msal_app(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h3>Announcements</h3>
<p>[Windows only] Azure CLI is collecting feedback on using the <a href="https://learn.microsoft.com/windows/uwp/security/web-account-manager">Web Account Manager</a> (WAM) broker for the login experience.</p>
<p>You may opt-in to use WAM by running the following commands:</p>
<code>
az config set core.allow_broker=true<br>
az config set core.enable_broker_on_windows=true<br>
az account clear<br>
az login
</code>
Expand Down
6 changes: 3 additions & 3 deletions src/azure-cli-core/azure/cli/core/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ def set_region_identified(region_input, region_identified):


@decorators.suppress_all_exceptions()
def set_broker_info(allow_broker):
# whether customer has configured `allow_broker` to enable WAM(Web Account Manager) login for authentication
_session.allow_broker = allow_broker
def set_broker_info(enable_broker_on_windows):
# Log the value of `enable_broker_on_windows`
_session.enable_broker_on_windows = enable_broker_on_windows


@decorators.suppress_all_exceptions()
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
'jmespath',
'knack~=0.11.0',
'msal-extensions~=1.0.0',
'msal[broker]==1.24.0b2',
'msal[broker]==1.26.0',
'msrestazure~=0.6.4',
'packaging>=20.9',
'paramiko>=2.0.8,<4.0.0',
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jsondiff==2.0.0
knack==0.11.0
MarkupSafe==2.0.1
msal-extensions==1.0.0
msal[broker]==1.24.0b2
msal[broker]==1.26.0
msrest==0.7.1
msrestazure==0.6.4
oauthlib==3.2.2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jsondiff==2.0.0
knack==0.11.0
MarkupSafe==2.0.1
msal-extensions==1.0.0
msal[broker]==1.24.0b2
msal[broker]==1.26.0
msrest==0.7.1
msrestazure==0.6.4
oauthlib==3.2.2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jsondiff==2.0.0
knack==0.11.0
MarkupSafe==2.0.1
msal-extensions==1.0.0
msal[broker]==1.24.0b2
msal[broker]==1.26.0
msrest==0.7.1
msrestazure==0.6.4
oauthlib==3.2.2
Expand Down

0 comments on commit 45d1a69

Please sign in to comment.