Skip to content

Commit 76f68de

Browse files
committed
update
1 parent e4138f0 commit 76f68de

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,22 +221,21 @@ def login_with_managed_identity(self, identity_id=None, allow_no_subscriptions=N
221221
identity_type = MsiAccountTypes.system_assigned
222222
from .auth.msal_authentication import ManagedIdentityCredential
223223
cred = ManagedIdentityCredential()
224-
token = cred.get_token(self._arm_scope).token
224+
token = cred.get_token(*self._arm_scope).token
225225
else:
226-
import jwt
227226
from azure.mgmt.core.tools import is_valid_resource_id
228227
from azure.cli.core.auth.adal_authentication import MSIAuthenticationWrapper
229228
resource = self.cli_ctx.cloud.endpoints.active_directory_resource_id
230229

231230
if identity_id:
232231
if is_valid_resource_id(identity_id):
233-
msi_creds = MSIAuthenticationWrapper(resource=resource, msi_res_id=identity_id)
232+
cred = MSIAuthenticationWrapper(resource=resource, msi_res_id=identity_id)
234233
identity_type = MsiAccountTypes.user_assigned_resource_id
235234
else:
236235
authenticated = False
237236
from azure.cli.core.azclierror import AzureResponseError
238237
try:
239-
msi_creds = MSIAuthenticationWrapper(resource=resource, client_id=identity_id)
238+
cred = MSIAuthenticationWrapper(resource=resource, client_id=identity_id)
240239
identity_type = MsiAccountTypes.user_assigned_client_id
241240
authenticated = True
242241
except AzureResponseError as ex:
@@ -248,7 +247,7 @@ def login_with_managed_identity(self, identity_id=None, allow_no_subscriptions=N
248247
if not authenticated:
249248
try:
250249
identity_type = MsiAccountTypes.user_assigned_object_id
251-
msi_creds = MSIAuthenticationWrapper(resource=resource, object_id=identity_id)
250+
cred = MSIAuthenticationWrapper(resource=resource, object_id=identity_id)
252251
authenticated = True
253252
except AzureResponseError as ex:
254253
if 'http error: 400, reason: Bad Request' in ex.error_msg:
@@ -261,17 +260,18 @@ def login_with_managed_identity(self, identity_id=None, allow_no_subscriptions=N
261260

262261
else:
263262
identity_type = MsiAccountTypes.system_assigned
264-
msi_creds = MSIAuthenticationWrapper(resource=resource)
263+
cred = MSIAuthenticationWrapper(resource=resource)
265264

266-
token_entry = msi_creds.token
265+
token_entry = cred.token
267266
token = token_entry['access_token']
268267

269268
logger.info('MSI: token was retrieved. Now trying to initialize local accounts...')
269+
import jwt
270270
decode = jwt.decode(token, algorithms=['RS256'], options={"verify_signature": False})
271271
tenant = decode['tid']
272272

273273
subscription_finder = SubscriptionFinder(self.cli_ctx)
274-
subscriptions = subscription_finder.find_using_specific_tenant(tenant, msi_creds)
274+
subscriptions = subscription_finder.find_using_specific_tenant(tenant, cred)
275275
base_name = ('{}-{}'.format(identity_type, identity_id) if identity_id else identity_type)
276276
user = _USER_ASSIGNED_IDENTITY if identity_id else _SYSTEM_ASSIGNED_IDENTITY
277277
if not subscriptions:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def get_token(self, *scopes, **kwargs):
141141
return build_sdk_access_token(result)
142142

143143

144-
class ManagedIdentityCredential:
144+
class ManagedIdentityCredential: # pylint: disable=too-few-public-methods
145145
"""Currently, only Azure Arc's system-assigned managed identity is supported.
146146
"""
147147

0 commit comments

Comments
 (0)