Skip to content

Commit ebf6ddf

Browse files
authored
{Profile} Show different ROPC flow warning messages in different clouds (#31310)
1 parent 46e301b commit ebf6ddf

File tree

1 file changed

+13
-4
lines changed
  • src/azure-cli/azure/cli/command_modules/profile

1 file changed

+13
-4
lines changed

src/azure-cli/azure/cli/command_modules/profile/custom.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@
4141
"[Warning] The login output has been updated. Please be aware that it no longer displays the full list of "
4242
"available subscriptions by default.\n")
4343

44-
USERNAME_PASSWORD_DEPRECATION_WARNING = (
45-
"Authentication with username and password in the command line is strongly discouraged. "
46-
"Use one of the recommended authentication methods based on your requirements. "
44+
USERNAME_PASSWORD_DEPRECATION_WARNING_AZURE_CLOUD = (
45+
"Starting July 01, 2025, MFA will be gradually enforced for Azure public cloud. "
46+
"The authentication with username and password in the command line is not supported with MFA. "
47+
"Consider using one of the compatible authentication methods. "
48+
"For more details, see https://go.microsoft.com/fwlink/?linkid=2276314")
49+
50+
USERNAME_PASSWORD_DEPRECATION_WARNING_OTHER_CLOUD = (
51+
"Using authentication with username and password in the command line is strongly discouraged. "
52+
"Consider using one of the recommended authentication methods. "
4753
"For more details, see https://go.microsoft.com/fwlink/?linkid=2276314")
4854

4955

@@ -134,7 +140,10 @@ def login(cmd, username=None, password=None, tenant=None, scopes=None, allow_no_
134140
if service_principal and not username:
135141
raise CLIError('usage error: --service-principal --username NAME --password SECRET --tenant TENANT')
136142
if username and not service_principal and not identity:
137-
logger.warning(USERNAME_PASSWORD_DEPRECATION_WARNING)
143+
if cmd.cli_ctx.cloud.endpoints.active_directory.startswith('https://login.microsoftonline.com'):
144+
logger.warning(USERNAME_PASSWORD_DEPRECATION_WARNING_AZURE_CLOUD)
145+
else:
146+
logger.warning(USERNAME_PASSWORD_DEPRECATION_WARNING_OTHER_CLOUD)
138147

139148
interactive = False
140149

0 commit comments

Comments
 (0)