-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Core] PREVIEW: Support MSAL managed identity #31092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |||||||
| from knack.log import get_logger | ||||||||
| from knack.util import CLIError | ||||||||
| from msal import (PublicClientApplication, ConfidentialClientApplication, | ||||||||
| ManagedIdentityClient, SystemAssignedManagedIdentity) | ||||||||
| ManagedIdentityClient, SystemAssignedManagedIdentity, UserAssignedManagedIdentity) | ||||||||
|
|
||||||||
| from .constants import AZURE_CLI_CLIENT_ID | ||||||||
| from .util import check_result | ||||||||
|
|
@@ -131,9 +131,14 @@ class ManagedIdentityCredential: # pylint: disable=too-few-public-methods | |||||||
| Currently, only Azure Arc's system-assigned managed identity is supported. | ||||||||
| """ | ||||||||
|
|
||||||||
| def __init__(self): | ||||||||
| def __init__(self, client_id=None, resource_id=None, object_id=None): | ||||||||
| import requests | ||||||||
| self._msal_client = ManagedIdentityClient(SystemAssignedManagedIdentity(), http_client=requests.Session()) | ||||||||
| if client_id or resource_id or object_id: | ||||||||
| managed_identity = UserAssignedManagedIdentity( | ||||||||
| client_id=client_id, resource_id=resource_id, object_id=object_id) | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note (unblocking)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already check this by ourselves: azure-cli/src/azure-cli-core/azure/cli/core/_profile.py Lines 817 to 819 in 17444a3
|
||||||||
| else: | ||||||||
| managed_identity = SystemAssignedManagedIdentity() | ||||||||
| self._msal_client = ManagedIdentityClient(managed_identity, http_client=requests.Session()) | ||||||||
|
|
||||||||
| def acquire_token(self, scopes, **kwargs): | ||||||||
| logger.debug("ManagedIdentityCredential.acquire_token: scopes=%r, kwargs=%r", scopes, kwargs) | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous variable name
identity_typeis not accurate. Identity type meanssystemAssignedIdentityoruserAssignedIdentity.