Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
66359b8
document async transport requirement (#6541)
chlowell Jul 30, 2019
379c1a1
[AutoPR] alertsmanagement/resource-manager (#5697)
AutorestCI Jul 30, 2019
7a0f5d3
Synchronous username/password auth (#6416)
chlowell Jul 30, 2019
f9f2db1
Synchronous interactive browser authentication (#6466)
chlowell Jul 30, 2019
f583901
we dont need thread locks (#6551)
SuyogSoti Jul 30, 2019
e833df0
KV aiohttp by default (#6563)
lmazuel Jul 31, 2019
95220b7
[AutoPR hanaonazure/resource-manager] Removing monitoring hana instan…
AutorestCI Jul 31, 2019
02e17b7
KV moved paging return type to ItemPaged (#6558)
lmazuel Jul 31, 2019
37c46c6
azure-core history 1.0.0b2 (#6562)
lmazuel Jul 31, 2019
c6ebc93
Make private Cosmos modules private [WIP] (#6329)
bryevdv Jul 31, 2019
d3d96df
Accept extension of JSON content-type (#6583)
lmazuel Jul 31, 2019
d2ed7d8
Remove docdb mgmt package from master (#6585)
lmazuel Jul 31, 2019
92583cf
Revert "Remove docdb mgmt package from master (#6585)" (#6593)
lmazuel Jul 31, 2019
1d86ae8
azure-core black/pylint/mypy (#6581)
lmazuel Aug 1, 2019
a08c25a
adjusting to allow default omission of packages for CI. (#6595)
scbedd Aug 1, 2019
b0bd437
Synchronous device code credential (#6464)
chlowell Aug 1, 2019
f700299
[AutoPR alertsmanagement/resource-manager] fixing subscription id iss…
AutorestCI Aug 1, 2019
64b121c
Remove Configuration from public API (#6603)
chlowell Aug 1, 2019
ccd73c1
[AutoPR] security/resource-manager (#5709)
AutorestCI Aug 1, 2019
33d6e4a
Minimal change to disable code coverage publishing for PRs. (#6614)
mitchdenny Aug 1, 2019
0249a7c
Readme doc update for azure-core (#6611)
lmazuel Aug 1, 2019
e12b658
Mypy fixes for azure.core.tracing (#6590)
SuyogSoti Aug 2, 2019
abc3f20
MyPy azure-core (#6619)
lmazuel Aug 2, 2019
8eb5e9b
Update Key Vault docstrings (#6632)
chlowell Aug 2, 2019
2a7a965
Update Key Vault user agent (#6640)
chlowell Aug 2, 2019
b647582
Update README.md (#6635)
lmazuel Aug 2, 2019
f9ab732
mypy fixes (#6641)
SuyogSoti Aug 2, 2019
46c7ad6
Policies as kwargs for KeyVault (#6616)
lmazuel Aug 3, 2019
5b5ed26
Mypy fixes (#6646)
xiangyan99 Aug 3, 2019
8d17ca3
[AutoPR healthcareapis/resource-manager] Fixed healthcareapi readme.m…
AutorestCI Aug 5, 2019
c257006
fixed bug in maxItemCount propagation for Order by queries (#6608)
Aug 5, 2019
4470f79
Final azure-identity preview 2 changes (#6664)
chlowell Aug 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove Configuration from public API (#6603)
  • Loading branch information
chlowell authored Aug 1, 2019
commit 64b121ca8ec2a22f3d7d6c1ab01490e9f146dbe3
4 changes: 2 additions & 2 deletions sdk/identity/azure-identity/azure/identity/_authn_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AuthnClient(AuthnClientBase):

def __init__(self, auth_url, config=None, policies=None, transport=None, **kwargs):
# type: (str, Optional[Configuration], Optional[Iterable[HTTPPolicy]], Optional[HttpTransport], Mapping[str, Any]) -> None
config = config or self.create_config(**kwargs)
config = config or self._create_config(**kwargs)
policies = policies or [ContentDecodePolicy(), config.retry_policy, config.logging_policy, DistributedTracingPolicy()]
if not transport:
transport = RequestsTransport(**kwargs)
Expand All @@ -135,7 +135,7 @@ def request_token(self, scopes, method="POST", headers=None, form_data=None, par
return token

@staticmethod
def create_config(**kwargs):
def _create_config(**kwargs):
# type: (Mapping[str, Any]) -> Configuration
config = Configuration(**kwargs)
config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def __init__(self, **kwargs):
self._pipeline = self._build_pipeline(**kwargs)

@staticmethod
def create_config(**kwargs):
def _create_config(**kwargs):
# type: (Any) -> Configuration
config = Configuration(**kwargs)
config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
config.retry_policy = RetryPolicy(**kwargs)
return config

def _build_pipeline(self, config=None, policies=None, transport=None, **kwargs):
config = config or self.create_config(**kwargs)
config = config or self._create_config(**kwargs)
policies = policies or [ContentDecodePolicy(), config.retry_policy, config.logging_policy]
if not transport:
transport = RequestsTransport(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class _ManagedIdentityBase(object):
def __init__(self, endpoint, client_cls, config=None, client_id=None, **kwargs):
# type: (str, Type, Optional[Configuration], Optional[str], Any) -> None
self._client_id = client_id
config = config or self.create_config(**kwargs)
config = config or self._create_config(**kwargs)
policies = [ContentDecodePolicy(), config.headers_policy, config.retry_policy, config.logging_policy]
self._client = client_cls(endpoint, config, policies, **kwargs)

@staticmethod
def create_config(**kwargs):
def _create_config(**kwargs):
# type: (Mapping[str, Any]) -> Configuration
"""
Build a default configuration for the credential's HTTP pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
transport: Optional[AsyncHttpTransport] = None,
**kwargs: Mapping[str, Any]
) -> None:
config = config or self.create_config(**kwargs)
config = config or self._create_config(**kwargs)
policies = policies or [
ContentDecodePolicy(),
config.retry_policy,
Expand Down Expand Up @@ -55,7 +55,7 @@ async def request_token(
return token

@staticmethod
def create_config(**kwargs: Mapping[str, Any]) -> Configuration:
def _create_config(**kwargs: Mapping[str, Any]) -> Configuration:
config = Configuration(**kwargs)
config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
config.retry_policy = AsyncRetryPolicy(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def __init__(self, endpoint: str, config: Optional[Configuration] = None, **kwar
super().__init__(endpoint=endpoint, config=config, client_cls=AsyncAuthnClient, **kwargs)

@staticmethod
def create_config(**kwargs: Any) -> Configuration: # type: ignore
def _create_config(**kwargs: Any) -> Configuration: # type: ignore
"""
Build a default configuration for the credential's HTTP pipeline.

:rtype: :class:`azure.core.configuration`
"""
return _ManagedIdentityBase.create_config(retry_policy=AsyncRetryPolicy, **kwargs)
return _ManagedIdentityBase._create_config(retry_policy=AsyncRetryPolicy, **kwargs)


class ImdsCredential(_AsyncManagedIdentityBase):
Expand Down
39 changes: 5 additions & 34 deletions sdk/identity/azure-identity/azure/identity/aio/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,11 @@ class ClientSecretCredential(ClientSecretCredentialBase):
:param str client_id: the service principal's client ID
:param str secret: one of the service principal's client secrets
:param str tenant_id: ID of the service principal's tenant. Also called its 'directory' ID.
:param config: optional configuration for the underlying HTTP pipeline
:type config: :class:`azure.core.configuration`
"""

def __init__(
self,
client_id: str,
secret: str,
tenant_id: str,
config: Optional[Configuration] = None,
**kwargs: Mapping[str, Any]
) -> None:
def __init__(self, client_id: str, secret: str, tenant_id: str, **kwargs: Mapping[str, Any]) -> None:
super(ClientSecretCredential, self).__init__(client_id, secret, tenant_id, **kwargs)
self._client = AsyncAuthnClient(Endpoints.AAD_OAUTH2_V2_FORMAT.format(tenant_id), config, **kwargs)
self._client = AsyncAuthnClient(Endpoints.AAD_OAUTH2_V2_FORMAT.format(tenant_id), **kwargs)

async def get_token(self, *scopes: str) -> AccessToken:
"""
Expand All @@ -66,20 +57,11 @@ class CertificateCredential(CertificateCredentialBase):
:param str client_id: the service principal's client ID
:param str tenant_id: ID of the service principal's tenant. Also called its 'directory' ID.
:param str certificate_path: path to a PEM-encoded certificate file including the private key
:param config: optional configuration for the underlying HTTP pipeline
:type config: :class:`azure.core.configuration`
"""

def __init__(
self,
client_id: str,
tenant_id: str,
certificate_path: str,
config: Optional[Configuration] = None,
**kwargs: Mapping[str, Any]
) -> None:
def __init__(self, client_id: str, tenant_id: str, certificate_path: str, **kwargs: Mapping[str, Any]) -> None:
super(CertificateCredential, self).__init__(client_id, tenant_id, certificate_path, **kwargs)
self._client = AsyncAuthnClient(Endpoints.AAD_OAUTH2_V2_FORMAT.format(tenant_id), config, **kwargs)
self._client = AsyncAuthnClient(Endpoints.AAD_OAUTH2_V2_FORMAT.format(tenant_id), **kwargs)

async def get_token(self, *scopes: str) -> AccessToken:
"""
Expand Down Expand Up @@ -151,8 +133,6 @@ class ManagedIdentityCredential(object):
Authenticates with a managed identity in an App Service, Azure VM or Cloud Shell environment.

:param str client_id: Optional client ID of a user-assigned identity. Leave unspecified to use a system-assigned identity.
:param config: optional configuration for the underlying HTTP pipeline
:type config: :class:`azure.core.configuration`
"""

def __new__(cls, *args, **kwargs):
Expand All @@ -162,18 +142,9 @@ def __new__(cls, *args, **kwargs):

# the below methods are never called, because ManagedIdentityCredential can't be instantiated;
# they exist so tooling gets accurate signatures for Imds- and MsiCredential
def __init__(self, client_id: Optional[str] = None, config: Optional[Configuration] = None, **kwargs: Any) -> None:
def __init__(self, client_id: Optional[str] = None, **kwargs: Any) -> None:
pass

@staticmethod
def create_config(**kwargs: Dict[str, Any]) -> Configuration:
"""
Build a default configuration for the credential's HTTP pipeline.

:rtype: :class:`azure.core.configuration`
"""
return Configuration(**kwargs)

async def get_token(self, *scopes: str) -> AccessToken:
"""
Asynchronously request an access token for `scopes`.
Expand Down
32 changes: 8 additions & 24 deletions sdk/identity/azure-identity/azure/identity/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ class ClientSecretCredential(ClientSecretCredentialBase):
:param str client_id: the service principal's client ID
:param str secret: one of the service principal's client secrets
:param str tenant_id: ID of the service principal's tenant. Also called its 'directory' ID.
:param config: optional configuration for the underlying HTTP pipeline
:type config: :class:`azure.core.configuration`
"""

def __init__(self, client_id, secret, tenant_id, config=None, **kwargs):
# type: (str, str, str, Optional[Configuration], Mapping[str, Any]) -> None
def __init__(self, client_id, secret, tenant_id, **kwargs):
# type: (str, str, str, Mapping[str, Any]) -> None
super(ClientSecretCredential, self).__init__(client_id, secret, tenant_id, **kwargs)
self._client = AuthnClient(Endpoints.AAD_OAUTH2_V2_FORMAT.format(tenant_id), config, **kwargs)
self._client = AuthnClient(Endpoints.AAD_OAUTH2_V2_FORMAT.format(tenant_id), **kwargs)

def get_token(self, *scopes):
# type (*str) -> AccessToken
Expand All @@ -73,13 +71,11 @@ class CertificateCredential(CertificateCredentialBase):
:param str client_id: the service principal's client ID
:param str tenant_id: ID of the service principal's tenant. Also called its 'directory' ID.
:param str certificate_path: path to a PEM-encoded certificate file including the private key
:param config: optional configuration for the underlying HTTP pipeline
:type config: :class:`azure.core.configuration`
"""

def __init__(self, client_id, tenant_id, certificate_path, config=None, **kwargs):
# type: (str, str, str, Optional[Configuration], Mapping[str, Any]) -> None
self._client = AuthnClient(Endpoints.AAD_OAUTH2_V2_FORMAT.format(tenant_id), config, **kwargs)
def __init__(self, client_id, tenant_id, certificate_path, **kwargs):
# type: (str, str, str, Mapping[str, Any]) -> None
self._client = AuthnClient(Endpoints.AAD_OAUTH2_V2_FORMAT.format(tenant_id), **kwargs)
super(CertificateCredential, self).__init__(client_id, tenant_id, certificate_path, **kwargs)

def get_token(self, *scopes):
Expand Down Expand Up @@ -166,8 +162,6 @@ class ManagedIdentityCredential(object):
Authenticates with a managed identity in an App Service, Azure VM or Cloud Shell environment.

:param str client_id: Optional client ID of a user-assigned identity. Leave unspecified to use a system-assigned identity.
:param config: optional configuration for the underlying HTTP pipeline
:type config: :class:`azure.core.configuration`
"""

def __new__(cls, *args, **kwargs):
Expand All @@ -177,20 +171,10 @@ def __new__(cls, *args, **kwargs):

# the below methods are never called, because ManagedIdentityCredential can't be instantiated;
# they exist so tooling gets accurate signatures for Imds- and MsiCredential
def __init__(self, client_id=None, config=None, **kwargs):
# type: (Optional[str], Optional[Configuration], Any) -> None
def __init__(self, client_id=None, **kwargs):
# type: (Optional[str], Any) -> None
pass

@staticmethod
def create_config(**kwargs):
# type: (Dict[str, str]) -> Configuration
"""
Build a default configuration for the credential's HTTP pipeline.

:rtype: :class:`azure.core.configuration`
"""
return Configuration(**kwargs)

def get_token(self, *scopes):
# type (*str) -> AccessToken
"""
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/azure-identity/tests/test_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def test_imds_credential_retries():
)
mock_send = Mock(return_value=mock_response)

total_retries = ImdsCredential.create_config().retry_policy.total_retries
total_retries = ImdsCredential._create_config().retry_policy.total_retries

for status_code in (404, 429, 500):
mock_send.reset_mock()
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/azure-identity/tests/test_identity_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ async def test_imds_credential_retries():
)
mock_send = Mock(return_value=mock_response)

total_retries = ImdsCredential.create_config().retry_policy.total_retries
total_retries = ImdsCredential._create_config().retry_policy.total_retries

for status_code in (404, 429, 500):
mock_send.reset_mock()
Expand Down