Skip to content

Commit 01d0b99

Browse files
xiangyan99mccoyp
andauthored
Update Multi-Tenant support to incorporate Arch Board Feedback (#20940)
* Update Multi-Tenant support to incorporate Arch Board Feedback * update * update * updates * update * update * updates * update * update * update * Update sdk/identity/azure-identity/CHANGELOG.md Co-authored-by: McCoy Patiño <[email protected]> Co-authored-by: McCoy Patiño <[email protected]>
1 parent 14f9076 commit 01d0b99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+157
-599
lines changed

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
## 1.7.0b5 (Unreleased)
44

5-
### Features Added
6-
75
### Breaking Changes
6+
> These changes do not impact the API of stable versions such as 1.6.0.
7+
> Only code written against a beta version such as 1.7.0b1 may be affected.
88
9-
### Bugs Fixed
10-
11-
### Other Changes
9+
- The `allow_multitenant_authentication` argument has been removed and the default behavior is now as if it were true.
10+
The multitenant authentication feature can be totally disabled by setting the environment variable
11+
`AZURE_IDENTITY_DISABLE_MULTITENANTAUTH` to `True`.
12+
- `azure.identity.RegionalAuthority` is removed.
13+
- `regional_authority` argument is removed for `CertificateCredential` and `ClientSecretCredential`
1214

1315
## 1.7.0b4 (2021-09-09)
1416

sdk/identity/azure-identity/azure/identity/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""Credentials for Azure SDK clients."""
66

77
from ._auth_record import AuthenticationRecord
8-
from ._enums import RegionalAuthority
98
from ._exceptions import AuthenticationRequiredError, CredentialUnavailableError
109
from ._constants import AzureAuthorityHosts, KnownAuthorities
1110
from ._credentials import (
@@ -47,7 +46,6 @@
4746
"InteractiveBrowserCredential",
4847
"KnownAuthorities",
4948
"OnBehalfOfCredential",
50-
"RegionalAuthority",
5149
"ManagedIdentityCredential",
5250
"SharedTokenCacheCredential",
5351
"TokenCachePersistenceOptions",

sdk/identity/azure-identity/azure/identity/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class EnvironmentVariables:
4444
MSI_SECRET = "MSI_SECRET"
4545

4646
AZURE_AUTHORITY_HOST = "AZURE_AUTHORITY_HOST"
47-
AZURE_IDENTITY_ENABLE_LEGACY_TENANT_SELECTION = "AZURE_IDENTITY_ENABLE_LEGACY_TENANT_SELECTION"
47+
AZURE_IDENTITY_DISABLE_MULTITENANTAUTH = "AZURE_IDENTITY_DISABLE_MULTITENANTAUTH"
4848
AZURE_REGIONAL_AUTHORITY_NAME = "AZURE_REGIONAL_AUTHORITY_NAME"
4949

5050
AZURE_FEDERATED_TOKEN_FILE = "AZURE_FEDERATED_TOKEN_FILE"

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ class AzureApplicationCredential(ChainedTokenCredential):
4848
<https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview>`_ for an overview of
4949
managed identities.
5050
51-
:keyword bool allow_multitenant_authentication: when True, enables the credential to acquire tokens from any tenant
52-
the application or user is registered in. When False, which is the default, the credential will acquire tokens
53-
only from the tenant specified by **AZURE_TENANT_ID**. This argument doesn't apply to managed identity
54-
authentication.
5551
:keyword str authority: Authority of an Azure Active Directory endpoint, for example "login.microsoftonline.com",
5652
the authority for Azure Public Cloud, which is the default when no value is given for this keyword argument or
5753
environment variable AZURE_AUTHORITY_HOST. :class:`~azure.identity.AzureAuthorityHosts` defines authorities for

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ class AuthorizationCodeCredential(GetTokenMixin):
3030
the authority for Azure Public Cloud (which is the default). :class:`~azure.identity.AzureAuthorityHosts`
3131
defines authorities for other clouds.
3232
:keyword str client_secret: One of the application's client secrets. Required only for web apps and web APIs.
33-
:keyword bool allow_multitenant_authentication: when True, enables the credential to acquire tokens from any tenant
34-
the user is registered in. When False, which is the default, the credential will acquire tokens only from the
35-
user's home tenant or the tenant specified by **tenant_id**.
3633
"""
3734

3835
def __init__(self, tenant_id, client_id, authorization_code, redirect_uri, **kwargs):
@@ -67,8 +64,7 @@ def get_token(self, *scopes, **kwargs):
6764
redeeming the authorization code.
6865
6966
:param str scopes: desired scopes for the access token. This method requires at least one scope.
70-
:keyword str tenant_id: optional tenant to include in the token request. If **allow_multitenant_authentication**
71-
is False, specifying a tenant with this argument may raise an exception.
67+
:keyword str tenant_id: optional tenant to include in the token request.
7268
7369
:rtype: :class:`azure.core.credentials.AccessToken`
7470
:raises ~azure.core.exceptions.ClientAuthenticationError: authentication failed. The error's ``message``

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,8 @@ class AzureCliCredential(object):
3535
"""Authenticates by requesting a token from the Azure CLI.
3636
3737
This requires previously logging in to Azure via "az login", and will use the CLI's currently logged in identity.
38-
39-
:keyword bool allow_multitenant_authentication: when True, enables the credential to acquire tokens from any tenant
40-
the identity logged in to the Azure CLI is registered in. When False, which is the default, the credential will
41-
acquire tokens only from the tenant of the Azure CLI's active subscription.
4238
"""
4339

44-
def __init__(self, **kwargs):
45-
self._allow_multitenant = kwargs.get("allow_multitenant_authentication", False)
46-
4740
def __enter__(self):
4841
return self
4942

@@ -55,16 +48,15 @@ def close(self):
5548
"""Calling this method is unnecessary."""
5649

5750
@log_get_token("AzureCliCredential")
58-
def get_token(self, *scopes, **kwargs):
51+
def get_token(self, *scopes, **kwargs): # pylint: disable=no-self-use
5952
# type: (*str, **Any) -> AccessToken
6053
"""Request an access token for `scopes`.
6154
6255
This method is called automatically by Azure SDK clients. Applications calling this method directly must
6356
also handle token caching because this credential doesn't cache the tokens it acquires.
6457
6558
:param str scopes: desired scope for the access token. This credential allows only one scope per request.
66-
:keyword str tenant_id: optional tenant to include in the token request. If **allow_multitenant_authentication**
67-
is False, specifying a tenant with this argument may raise an exception.
59+
:keyword str tenant_id: optional tenant to include in the token request.
6860
6961
:rtype: :class:`azure.core.credentials.AccessToken`
7062
@@ -75,7 +67,7 @@ def get_token(self, *scopes, **kwargs):
7567

7668
resource = _scopes_to_resource(*scopes)
7769
command = COMMAND_LINE.format(resource)
78-
tenant = resolve_tenant("", self._allow_multitenant, **kwargs)
70+
tenant = resolve_tenant("", **kwargs)
7971
if tenant:
8072
command += " --tenant " + tenant
8173
output = _run_command(command)

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,8 @@ class AzurePowerShellCredential(object):
5151
"""Authenticates by requesting a token from Azure PowerShell.
5252
5353
This requires previously logging in to Azure via "Connect-AzAccount", and will use the currently logged in identity.
54-
55-
:keyword bool allow_multitenant_authentication: when True, enables the credential to acquire tokens from any tenant
56-
the identity logged in to Azure PowerShell is registered in. When False, which is the default, the credential
57-
will acquire tokens only from the tenant of Azure PowerShell's active subscription.
5854
"""
5955

60-
def __init__(self, **kwargs):
61-
# type: (**Any) -> None
62-
self._allow_multitenant = kwargs.get("allow_multitenant_authentication", False)
63-
6456
def __enter__(self):
6557
return self
6658

@@ -72,16 +64,15 @@ def close(self):
7264
"""Calling this method is unnecessary."""
7365

7466
@log_get_token("AzurePowerShellCredential")
75-
def get_token(self, *scopes, **kwargs):
67+
def get_token(self, *scopes, **kwargs): # pylint: disable=no-self-use
7668
# type: (*str, **Any) -> AccessToken
7769
"""Request an access token for `scopes`.
7870
7971
This method is called automatically by Azure SDK clients. Applications calling this method directly must
8072
also handle token caching because this credential doesn't cache the tokens it acquires.
8173
8274
:param str scopes: desired scope for the access token. This credential allows only one scope per request.
83-
:keyword str tenant_id: optional tenant to include in the token request. If **allow_multitenant_authentication**
84-
is False, specifying a tenant with this argument may raise an exception.
75+
:keyword str tenant_id: optional tenant to include in the token request.
8576
8677
:rtype: :class:`azure.core.credentials.AccessToken`
8778
@@ -90,7 +81,7 @@ def get_token(self, *scopes, **kwargs):
9081
:raises ~azure.core.exceptions.ClientAuthenticationError: the credential invoked Azure PowerShell but didn't
9182
receive an access token
9283
"""
93-
tenant_id = resolve_tenant("", self._allow_multitenant, **kwargs)
84+
tenant_id = resolve_tenant("", **kwargs)
9485
command_line = get_command_line(scopes, tenant_id)
9586
output = run_command_line(command_line)
9687
token = parse_token(output)

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ class InteractiveBrowserCredential(InteractiveCredential):
5151
will cache tokens in memory.
5252
:paramtype cache_persistence_options: ~azure.identity.TokenCachePersistenceOptions
5353
:keyword int timeout: seconds to wait for the user to complete authentication. Defaults to 300 (5 minutes).
54-
:keyword bool allow_multitenant_authentication: when True, enables the credential to acquire tokens from any tenant
55-
the user is registered in. When False, which is the default, the credential will acquire tokens only from the
56-
user's home tenant or the tenant specified by **tenant_id**.
5754
:raises ValueError: invalid **redirect_uri**
5855
"""
5956

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,12 @@ class CertificateCredential(ClientCredentialBase):
3939
:keyword password: The certificate's password. If a unicode string, it will be encoded as UTF-8. If the certificate
4040
requires a different encoding, pass appropriately encoded bytes instead.
4141
:paramtype password: str or bytes
42-
:keyword bool allow_multitenant_authentication: when True, enables the credential to acquire tokens from any tenant
43-
the application is registered in. When False, which is the default, the credential will acquire tokens only from
44-
the tenant specified by **tenant_id**.
4542
:keyword bool send_certificate_chain: if True, the credential will send the public certificate chain in the x5c
4643
header of each token request's JWT. This is required for Subject Name/Issuer (SNI) authentication. Defaults to
4744
False.
4845
:keyword cache_persistence_options: configuration for persistent token caching. If unspecified, the credential
4946
will cache tokens in memory.
5047
:paramtype cache_persistence_options: ~azure.identity.TokenCachePersistenceOptions
51-
:keyword ~azure.identity.RegionalAuthority regional_authority: a :class:`~azure.identity.RegionalAuthority` to
52-
which the credential will authenticate. This argument should be used only by applications deployed to Azure
53-
VMs.
5448
"""
5549

5650
def __init__(self, tenant_id, client_id, certificate_path=None, **kwargs):

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,9 @@ class ClientSecretCredential(ClientCredentialBase):
2121
:keyword str authority: Authority of an Azure Active Directory endpoint, for example "login.microsoftonline.com",
2222
the authority for Azure Public Cloud (which is the default). :class:`~azure.identity.AzureAuthorityHosts`
2323
defines authorities for other clouds.
24-
:keyword bool allow_multitenant_authentication: when True, enables the credential to acquire tokens from any tenant
25-
the application is registered in. When False, which is the default, the credential will acquire tokens only from
26-
the tenant specified by **tenant_id**.
2724
:keyword cache_persistence_options: configuration for persistent token caching. If unspecified, the credential
2825
will cache tokens in memory.
2926
:paramtype cache_persistence_options: ~azure.identity.TokenCachePersistenceOptions
30-
:keyword ~azure.identity.RegionalAuthority regional_authority: a :class:`~azure.identity.RegionalAuthority` to
31-
which the credential will authenticate. This argument should be used only by applications deployed to Azure
32-
VMs.
3327
"""
3428

3529
def __init__(self, tenant_id, client_id, client_secret, **kwargs):

0 commit comments

Comments
 (0)