Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions sdk/core/azure-core/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

# Release History

## 1.2.1 (2020-01-14)

### Bug fixes

- Fixed a regression in 1.2.0 that was incompatible with azure-keyvault-* 4.0.0
[#9462](https://github.com/Azure/azure-sdk-for-python/issues/9462)


## 1.2.0 (2020-01-14)

### Features
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/azure/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# regenerated.
# --------------------------------------------------------------------------

VERSION = "1.2.0"
VERSION = "1.2.1"
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ class _BearerTokenCredentialPolicyBase(object):
:param str scopes: Lets you specify the type of access needed.
"""

def __init__(self, *scopes, **kwargs): # pylint:disable=unused-argument
# type: (*str, **Any) -> None
def __init__(self, credential, *scopes, **kwargs): # pylint:disable=unused-argument
# type: (TokenCredential, *str, Mapping[str, Any]) -> None
super(_BearerTokenCredentialPolicyBase, self).__init__()
self._scopes = scopes
self._credential = credential
self._token = None # type: Optional[AccessToken]

@staticmethod
Expand Down Expand Up @@ -68,11 +69,6 @@ class BearerTokenCredentialPolicy(_BearerTokenCredentialPolicyBase, SansIOHTTPPo
:raises: :class:`~azure.core.exceptions.ServiceRequestError`
"""

def __init__(self, credential, *scopes, **kwargs):
# type: (TokenCredential, *str, **Any) -> None
self._credential = credential
super(BearerTokenCredentialPolicy, self).__init__(*scopes, **kwargs)

def on_request(self, request):
# type: (PipelineRequest) -> None
"""Adds a bearer token Authorization header to request and sends request to next policy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,26 @@
# license information.
# -------------------------------------------------------------------------
import threading
from typing import TYPE_CHECKING

from azure.core.pipeline import PipelineRequest
from azure.core.pipeline.policies import SansIOHTTPPolicy
from azure.core.pipeline.policies._authentication import _BearerTokenCredentialPolicyBase

if TYPE_CHECKING:
# pylint:disable=unused-import
from typing import Any
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.pipeline import PipelineRequest


class AsyncBearerTokenCredentialPolicy(_BearerTokenCredentialPolicyBase, SansIOHTTPPolicy):
# pylint:disable=too-few-public-methods
"""Adds a bearer token Authorization header to requests.

:param credential: The credential.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:type credential: ~azure.core.credentials.TokenCredential
:param str scopes: Lets you specify the type of access needed.
"""

def __init__(self, credential: "AsyncTokenCredential", *scopes: str, **kwargs: "Any") -> None:
self._credential = credential
def __init__(self, credential, *scopes, **kwargs):
super().__init__(credential, *scopes, **kwargs)
self._lock = threading.Lock()
super().__init__(*scopes, **kwargs)

async def on_request(self, request: "PipelineRequest"):
async def on_request(self, request: PipelineRequest):
"""Adds a bearer token Authorization header to request and sends request to next policy.

:param request: The pipeline request object to be modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,18 @@
requirements can change. For example, a vault may move to a new tenant. In such a case the policy will attempt the
protocol again.
"""
from typing import TYPE_CHECKING

from azure.core.pipeline import PipelineRequest
from azure.core.pipeline.policies import AsyncHTTPPolicy
from azure.core.pipeline.transport import HttpResponse

from . import ChallengeAuthPolicyBase, HttpChallengeCache

if TYPE_CHECKING:
from typing import Any
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.pipeline import PipelineRequest
from azure.core.pipeline.transport import HttpResponse
from . import HttpChallenge
from . import ChallengeAuthPolicyBase, HttpChallenge, HttpChallengeCache


class AsyncChallengeAuthPolicy(ChallengeAuthPolicyBase, AsyncHTTPPolicy):
"""policy for handling HTTP authentication challenges"""

def __init__(self, credential: "AsyncTokenCredential", **kwargs: "Any") -> None:
self._credential = credential
super().__init__(**kwargs)

async def send(self, request: "PipelineRequest") -> "HttpResponse":
async def send(self, request: PipelineRequest) -> HttpResponse:
self._enforce_tls(request)

challenge = HttpChallengeCache.get_challenge_for_url(request.http_request.url)
Expand Down Expand Up @@ -66,7 +56,7 @@ async def send(self, request: "PipelineRequest") -> "HttpResponse":

return response

async def _handle_challenge(self, request: "PipelineRequest", challenge: "HttpChallenge") -> None:
async def _handle_challenge(self, request: PipelineRequest, challenge: HttpChallenge) -> None:
"""authenticate according to challenge, add Authorization header to request"""

if self._need_new_token:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@

if TYPE_CHECKING:
# pylint:disable=unused-import
from typing import Any
from azure.core.credentials import TokenCredential
from azure.core.pipeline.transport import HttpResponse


class ChallengeAuthPolicyBase(_BearerTokenCredentialPolicyBase):
"""Sans I/O base for challenge authentication policies"""

# pylint:disable=useless-super-delegation
def __init__(self, credential, **kwargs):
super(ChallengeAuthPolicyBase, self).__init__(credential, **kwargs)

@staticmethod
def _update_challenge(request, challenger):
# type: (HttpRequest, HttpResponse) -> HttpChallenge
Expand Down Expand Up @@ -72,11 +74,6 @@ def _get_challenge_request(request):
class ChallengeAuthPolicy(ChallengeAuthPolicyBase, HTTPPolicy):
"""policy for handling HTTP authentication challenges"""

def __init__(self, credential, **kwargs):
# type: (TokenCredential, **Any) -> None
self._credential = credential
super(ChallengeAuthPolicy, self).__init__(**kwargs)

def send(self, request):
# type: (PipelineRequest) -> HttpResponse
self._enforce_tls(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,18 @@
requirements can change. For example, a vault may move to a new tenant. In such a case the policy will attempt the
protocol again.
"""
from typing import TYPE_CHECKING

from azure.core.pipeline import PipelineRequest
from azure.core.pipeline.policies import AsyncHTTPPolicy
from azure.core.pipeline.transport import HttpResponse

from . import ChallengeAuthPolicyBase, HttpChallengeCache

if TYPE_CHECKING:
from typing import Any
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.pipeline import PipelineRequest
from azure.core.pipeline.transport import HttpResponse
from . import HttpChallenge
from . import ChallengeAuthPolicyBase, HttpChallenge, HttpChallengeCache


class AsyncChallengeAuthPolicy(ChallengeAuthPolicyBase, AsyncHTTPPolicy):
"""policy for handling HTTP authentication challenges"""

def __init__(self, credential: "AsyncTokenCredential", **kwargs: "Any") -> None:
self._credential = credential
super().__init__(**kwargs)

async def send(self, request: "PipelineRequest") -> "HttpResponse":
async def send(self, request: PipelineRequest) -> HttpResponse:
self._enforce_tls(request)

challenge = HttpChallengeCache.get_challenge_for_url(request.http_request.url)
Expand Down Expand Up @@ -66,7 +56,7 @@ async def send(self, request: "PipelineRequest") -> "HttpResponse":

return response

async def _handle_challenge(self, request: "PipelineRequest", challenge: "HttpChallenge") -> None:
async def _handle_challenge(self, request: PipelineRequest, challenge: HttpChallenge) -> None:
"""authenticate according to challenge, add Authorization header to request"""

if self._need_new_token:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@

if TYPE_CHECKING:
# pylint:disable=unused-import
from typing import Any
from azure.core.credentials import TokenCredential
from azure.core.pipeline.transport import HttpResponse


class ChallengeAuthPolicyBase(_BearerTokenCredentialPolicyBase):
"""Sans I/O base for challenge authentication policies"""

# pylint:disable=useless-super-delegation
def __init__(self, credential, **kwargs):
super(ChallengeAuthPolicyBase, self).__init__(credential, **kwargs)

@staticmethod
def _update_challenge(request, challenger):
# type: (HttpRequest, HttpResponse) -> HttpChallenge
Expand Down Expand Up @@ -72,11 +74,6 @@ def _get_challenge_request(request):
class ChallengeAuthPolicy(ChallengeAuthPolicyBase, HTTPPolicy):
"""policy for handling HTTP authentication challenges"""

def __init__(self, credential, **kwargs):
# type: (TokenCredential, **Any) -> None
self._credential = credential
super(ChallengeAuthPolicy, self).__init__(**kwargs)

def send(self, request):
# type: (PipelineRequest) -> HttpResponse
self._enforce_tls(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,18 @@
requirements can change. For example, a vault may move to a new tenant. In such a case the policy will attempt the
protocol again.
"""
from typing import TYPE_CHECKING

from azure.core.pipeline import PipelineRequest
from azure.core.pipeline.policies import AsyncHTTPPolicy
from azure.core.pipeline.transport import HttpResponse

from . import ChallengeAuthPolicyBase, HttpChallengeCache

if TYPE_CHECKING:
from typing import Any
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.pipeline import PipelineRequest
from azure.core.pipeline.transport import HttpResponse
from . import HttpChallenge
from . import ChallengeAuthPolicyBase, HttpChallenge, HttpChallengeCache


class AsyncChallengeAuthPolicy(ChallengeAuthPolicyBase, AsyncHTTPPolicy):
"""policy for handling HTTP authentication challenges"""

def __init__(self, credential: "AsyncTokenCredential", **kwargs: "Any") -> None:
self._credential = credential
super().__init__(**kwargs)

async def send(self, request: "PipelineRequest") -> "HttpResponse":
async def send(self, request: PipelineRequest) -> HttpResponse:
self._enforce_tls(request)

challenge = HttpChallengeCache.get_challenge_for_url(request.http_request.url)
Expand Down Expand Up @@ -66,7 +56,7 @@ async def send(self, request: "PipelineRequest") -> "HttpResponse":

return response

async def _handle_challenge(self, request: "PipelineRequest", challenge: "HttpChallenge") -> None:
async def _handle_challenge(self, request: PipelineRequest, challenge: HttpChallenge) -> None:
"""authenticate according to challenge, add Authorization header to request"""

if self._need_new_token:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@

if TYPE_CHECKING:
# pylint:disable=unused-import
from typing import Any
from azure.core.credentials import TokenCredential
from azure.core.pipeline.transport import HttpResponse


class ChallengeAuthPolicyBase(_BearerTokenCredentialPolicyBase):
"""Sans I/O base for challenge authentication policies"""

# pylint:disable=useless-super-delegation
def __init__(self, credential, **kwargs):
super(ChallengeAuthPolicyBase, self).__init__(credential, **kwargs)

@staticmethod
def _update_challenge(request, challenger):
# type: (HttpRequest, HttpResponse) -> HttpChallenge
Expand Down Expand Up @@ -72,11 +74,6 @@ def _get_challenge_request(request):
class ChallengeAuthPolicy(ChallengeAuthPolicyBase, HTTPPolicy):
"""policy for handling HTTP authentication challenges"""

def __init__(self, credential, **kwargs):
# type: (TokenCredential, **Any) -> None
self._credential = credential
super(ChallengeAuthPolicy, self).__init__(**kwargs)

def send(self, request):
# type: (PipelineRequest) -> HttpResponse
self._enforce_tls(request)
Expand Down