Skip to content

Commit 21b30b6

Browse files
authored
RC (#26733)
1 parent d958d6b commit 21b30b6

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

sdk/identity/azure-identity/CHANGELOG.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
# Release History
22

3-
## 1.12.0b2 (Unreleased)
3+
## 1.12.0b2 (2022-10-11)
44

5-
### Features Added
6-
7-
### Breaking Changes
8-
9-
### Bugs Fixed
10-
11-
### Other Changes
5+
1.12.0 release candidate
126

137
## 1.12.0b1 (2022-09-22)
148

sdk/identity/azure-identity/azure/identity/_credentials/default.py

+19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .managed_identity import ManagedIdentityCredential
1515
from .shared_cache import SharedTokenCacheCredential
1616
from .azure_cli import AzureCliCredential
17+
from .vscode import VisualStudioCodeCredential
1718

1819

1920
try:
@@ -54,6 +55,8 @@ class DefaultAzureCredential(ChainedTokenCredential):
5455
:keyword bool exclude_managed_identity_credential: Whether to exclude managed identity from the credential.
5556
Defaults to **False**.
5657
:keyword bool exclude_powershell_credential: Whether to exclude Azure PowerShell. Defaults to **False**.
58+
:keyword bool exclude_visual_studio_code_credential: Whether to exclude stored credential from VS Code.
59+
Defaults to **True**.
5760
:keyword bool exclude_shared_token_cache_credential: Whether to exclude the shared token cache. Defaults to
5861
**False**.
5962
:keyword bool exclude_interactive_browser_credential: Whether to exclude interactive browser authentication (see
@@ -69,6 +72,10 @@ class DefaultAzureCredential(ChainedTokenCredential):
6972
Defaults to the value of environment variable AZURE_USERNAME, if any.
7073
:keyword str shared_cache_tenant_id: Preferred tenant for :class:`~azure.identity.SharedTokenCacheCredential`.
7174
Defaults to the value of environment variable AZURE_TENANT_ID, if any.
75+
:keyword str visual_studio_code_tenant_id: Tenant ID to use when authenticating with
76+
:class:`~azure.identity.VisualStudioCodeCredential`. Defaults to the "Azure: Tenant" setting in VS Code's user
77+
settings or, when that setting has no value, the "organizations" tenant, which supports only Azure Active
78+
Directory work or school accounts.
7279
"""
7380

7481
def __init__(self, **kwargs):
@@ -78,6 +85,15 @@ def __init__(self, **kwargs):
7885

7986
authority = kwargs.pop("authority", None)
8087

88+
vscode_tenant_id = kwargs.pop(
89+
"visual_studio_code_tenant_id", os.environ.get(EnvironmentVariables.AZURE_TENANT_ID)
90+
)
91+
vscode_args = dict(kwargs)
92+
if authority:
93+
vscode_args["authority"] = authority
94+
if vscode_tenant_id:
95+
vscode_args["tenant_id"] = vscode_tenant_id
96+
8197
authority = normalize_authority(authority) if authority else get_default_authority()
8298

8399
interactive_browser_tenant_id = kwargs.pop(
@@ -97,6 +113,7 @@ def __init__(self, **kwargs):
97113
exclude_environment_credential = kwargs.pop("exclude_environment_credential", False)
98114
exclude_managed_identity_credential = kwargs.pop("exclude_managed_identity_credential", False)
99115
exclude_shared_token_cache_credential = kwargs.pop("exclude_shared_token_cache_credential", False)
116+
exclude_visual_studio_code_credential = kwargs.pop("exclude_visual_studio_code_credential", True)
100117
exclude_cli_credential = kwargs.pop("exclude_cli_credential", False)
101118
exclude_interactive_browser_credential = kwargs.pop("exclude_interactive_browser_credential", True)
102119
exclude_powershell_credential = kwargs.pop("exclude_powershell_credential", False)
@@ -115,6 +132,8 @@ def __init__(self, **kwargs):
115132
credentials.append(shared_cache)
116133
except Exception as ex: # pylint:disable=broad-except
117134
_LOGGER.info("Shared token cache is unavailable: '%s'", ex)
135+
if not exclude_visual_studio_code_credential:
136+
credentials.append(VisualStudioCodeCredential(**vscode_args))
118137
if not exclude_cli_credential:
119138
credentials.append(AzureCliCredential())
120139
if not exclude_powershell_credential:

sdk/identity/azure-identity/azure/identity/aio/_credentials/default.py

+23
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .environment import EnvironmentCredential
1515
from .managed_identity import ManagedIdentityCredential
1616
from .shared_cache import SharedTokenCacheCredential
17+
from .vscode import VisualStudioCodeCredential
1718

1819
if TYPE_CHECKING:
1920
from typing import Any, List
@@ -47,6 +48,8 @@ class DefaultAzureCredential(ChainedTokenCredential):
4748
:keyword bool exclude_environment_credential: Whether to exclude a service principal configured by environment
4849
variables from the credential. Defaults to **False**.
4950
:keyword bool exclude_powershell_credential: Whether to exclude Azure PowerShell. Defaults to **False**.
51+
:keyword bool exclude_visual_studio_code_credential: Whether to exclude stored credential from VS Code.
52+
Defaults to **True**.
5053
:keyword bool exclude_managed_identity_credential: Whether to exclude managed identity from the credential.
5154
Defaults to **False**.
5255
:keyword bool exclude_shared_token_cache_credential: Whether to exclude the shared token cache. Defaults to
@@ -57,6 +60,10 @@ class DefaultAzureCredential(ChainedTokenCredential):
5760
Defaults to the value of environment variable AZURE_USERNAME, if any.
5861
:keyword str shared_cache_tenant_id: Preferred tenant for :class:`~azure.identity.aio.SharedTokenCacheCredential`.
5962
Defaults to the value of environment variable AZURE_TENANT_ID, if any.
63+
:keyword str visual_studio_code_tenant_id: Tenant ID to use when authenticating with
64+
:class:`~azure.identity.aio.VisualStudioCodeCredential`. Defaults to the "Azure: Tenant" setting in VS Code's
65+
user settings or, when that setting has no value, the "organizations" tenant, which supports only Azure Active
66+
Directory work or school accounts.
6067
"""
6168

6269
def __init__(self, **kwargs: "Any") -> None:
@@ -65,6 +72,15 @@ def __init__(self, **kwargs: "Any") -> None:
6572

6673
authority = kwargs.pop("authority", None)
6774

75+
vscode_tenant_id = kwargs.pop(
76+
"visual_studio_code_tenant_id", os.environ.get(EnvironmentVariables.AZURE_TENANT_ID)
77+
)
78+
vscode_args = dict(kwargs)
79+
if authority:
80+
vscode_args["authority"] = authority
81+
if vscode_tenant_id:
82+
vscode_args["tenant_id"] = vscode_tenant_id
83+
6884
authority = normalize_authority(authority) if authority else get_default_authority()
6985

7086
shared_cache_username = kwargs.pop("shared_cache_username", os.environ.get(EnvironmentVariables.AZURE_USERNAME))
@@ -76,6 +92,11 @@ def __init__(self, **kwargs: "Any") -> None:
7692
"managed_identity_client_id", os.environ.get(EnvironmentVariables.AZURE_CLIENT_ID)
7793
)
7894

95+
vscode_tenant_id = kwargs.pop(
96+
"visual_studio_code_tenant_id", os.environ.get(EnvironmentVariables.AZURE_TENANT_ID)
97+
)
98+
99+
exclude_visual_studio_code_credential = kwargs.pop("exclude_visual_studio_code_credential", True)
79100
exclude_cli_credential = kwargs.pop("exclude_cli_credential", False)
80101
exclude_environment_credential = kwargs.pop("exclude_environment_credential", False)
81102
exclude_managed_identity_credential = kwargs.pop("exclude_managed_identity_credential", False)
@@ -96,6 +117,8 @@ def __init__(self, **kwargs: "Any") -> None:
96117
credentials.append(shared_cache)
97118
except Exception as ex: # pylint:disable=broad-except
98119
_LOGGER.info("Shared token cache is unavailable: '%s'", ex)
120+
if not exclude_visual_studio_code_credential:
121+
credentials.append(VisualStudioCodeCredential(**vscode_args))
99122
if not exclude_cli_credential:
100123
credentials.append(AzureCliCredential())
101124
if not exclude_powershell_credential:

0 commit comments

Comments
 (0)