-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add EnvVar AZURE_AUTHORITY_HOST #10357
Conversation
Can one of the admins verify this patch? |
sdk/identity/azure-identity/azure/identity/_credentials/default.py
Outdated
Show resolved
Hide resolved
sdk/identity/azure-identity/azure/identity/_internal/shared_token_cache.py
Outdated
Show resolved
Hide resolved
Can you please add tests? |
The base branch was changed.
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.
I agree with Jon, this deserves test coverage. Please also format with black -l 120
.
@@ -34,7 +34,7 @@ class AadClientBase(ABC): | |||
|
|||
def __init__(self, tenant_id, client_id, cache=None, **kwargs): | |||
# type: (str, str, Optional[TokenCache], **Any) -> None | |||
authority = kwargs.pop("authority", KnownAuthorities.AZURE_PUBLIC_CLOUD) | |||
authority = kwargs.pop("authority", None) or get_default_authority() |
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.
Not authority = kwargs.pop("authority", get_default_authority())?
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.
Yes, for two reasons:
- to make
authority=None
get the default value - to prevent invoking
get_default_authority
when a value was passed
@@ -10,6 +10,7 @@ | |||
|
|||
from .. import CredentialUnavailableError | |||
from .._constants import KnownAuthorities |
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.
Do we still need it?
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.
Yes, it's used to build the sets of authority aliases.
@@ -61,7 +62,7 @@ class DefaultAzureCredential(ChainedTokenCredential): | |||
""" | |||
|
|||
def __init__(self, **kwargs): | |||
authority = kwargs.pop("authority", None) or KnownAuthorities.AZURE_PUBLIC_CLOUD | |||
authority = kwargs.pop("authority", None) or get_default_authority() |
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.
Not authority = kwargs.pop("authority", get_default_authority())?
@@ -37,7 +37,7 @@ class MsalCredential(ABC): | |||
def __init__(self, client_id, client_credential=None, **kwargs): | |||
# type: (str, Optional[Union[str, Mapping[str, str]]], **Any) -> None | |||
tenant_id = kwargs.pop("tenant_id", "organizations") | |||
authority = kwargs.pop("authority", KnownAuthorities.AZURE_PUBLIC_CLOUD) | |||
authority = kwargs.pop("authority", None) or get_default_authority() |
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.
same
Added EnvVar AZURE_AUTHORITY_HOST to azure.identity._constants.
TokenCredentialOptions has an AuthorityHost property.
This will be modified to support EnvVar override with AZURE_AUTHORITY_HOST.
Azure/azure-sdk-for-java/issues/5967