Skip to content

Commit

Permalink
add tenant log (Azure#21706)
Browse files Browse the repository at this point in the history
* add tenant log

* Update sdk/identity/azure-identity/azure/identity/_internal/__init__.py

Co-authored-by: McCoy Patiño <[email protected]>

* Update sdk/identity/azure-identity/azure/identity/_internal/__init__.py

Co-authored-by: McCoy Patiño <[email protected]>

* Update sdk/identity/azure-identity/azure/identity/_internal/__init__.py

Co-authored-by: McCoy Patiño <[email protected]>

* update

* update

* Update sdk/identity/azure-identity/azure/identity/_internal/__init__.py

Co-authored-by: McCoy Patiño <[email protected]>

Co-authored-by: McCoy Patiño <[email protected]>
  • Loading branch information
2 people authored and rakshith91 committed Nov 17, 2021
1 parent cd212d2 commit 929e841
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sdk/identity/azure-identity/azure/identity/_internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under the MIT License.
# ------------------------------------
import os
import logging
from typing import TYPE_CHECKING

from six.moves.urllib_parse import urlparse
Expand All @@ -29,6 +30,7 @@ def set(self, _):

within_credential_chain = AlwaysFalse() # type: ignore

_LOGGER = logging.getLogger(__name__)

def normalize_authority(authority):
# type: (str) -> str
Expand Down Expand Up @@ -67,13 +69,19 @@ def validate_tenant_id(tenant_id):
def resolve_tenant(default_tenant, tenant_id=None, **_):
# type: (str, Optional[str], **Any) -> str
"""Returns the correct tenant for a token request given a credential's configuration"""
if tenant_id is None:
return default_tenant
if (
tenant_id is None
or default_tenant == "adfs"
default_tenant == "adfs"
or os.environ.get(EnvironmentVariables.AZURE_IDENTITY_DISABLE_MULTITENANTAUTH)
):
_LOGGER.info("A token was request for a different tenant than was configured on the credential, "
"but the configured value was used since multi tenant authentication has been disabled. "
"Configured tenant ID: %s, Requested tenant ID %s", default_tenant, tenant_id)
return default_tenant

_LOGGER.info("A token was requested for a different tenant than was configured on the credential, "
"and the requested tenant ID was used to authenticate. Configured tenant ID: %s, "
"Requested tenant ID %s", default_tenant, tenant_id)
return tenant_id


Expand Down

0 comments on commit 929e841

Please sign in to comment.