diff --git a/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md b/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md index c7343bc789cd..bff700b96c99 100644 --- a/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md +++ b/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 4.11.2 (2026-08-25) + +### Bugs Fixed + +- Fixed the challenge authentication policy to cache the authentication challenge only after the challenge resource is verified, so that a rejected challenge is not cached and reused by subsequent requests. + ## 4.11.1 (2026-08-12) ### Bugs Fixed diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/async_challenge_auth_policy.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/async_challenge_auth_policy.py index 2cde1f17f0d0..95620bd9fc2d 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/async_challenge_auth_policy.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/async_challenge_auth_policy.py @@ -219,6 +219,8 @@ async def on_challenge(self, request: PipelineRequest, response: PipelineRespons "See https://aka.ms/azsdk/blog/vault-uri for more information." ) + ChallengeCache.set_challenge_for_url(request.http_request.url, challenge) + # If we stashed the original request in on_request, use it now to send along the original body content request_copy = request.context.get(_REQUEST_COPY_KEY) if request_copy: diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/challenge_auth_policy.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/challenge_auth_policy.py index 8d3685afc128..0f5f99993c56 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/challenge_auth_policy.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/challenge_auth_policy.py @@ -64,7 +64,7 @@ def _has_claims(challenge: str) -> bool: def _update_challenge(request: PipelineRequest, challenger: PipelineResponse) -> HttpChallenge: - """Parse challenge from a challenge response, cache it, and return it. + """Parse challenge from a challenge response and return it. :param request: The pipeline request that prompted the challenge response. :type request: ~azure.core.pipeline.PipelineRequest @@ -80,7 +80,6 @@ def _update_challenge(request: PipelineRequest, challenger: PipelineResponse) -> challenger.http_response.headers.get("WWW-Authenticate"), response_headers=challenger.http_response.headers, ) - ChallengeCache.set_challenge_for_url(request.http_request.url, challenge) return challenge @@ -234,6 +233,8 @@ def on_challenge(self, request: PipelineRequest, response: PipelineResponse) -> "See https://aka.ms/azsdk/blog/vault-uri for more information." ) + ChallengeCache.set_challenge_for_url(request.http_request.url, challenge) + # If we stashed the original request in on_request, use it now to send along the original body content request_copy = request.context.get(_REQUEST_COPY_KEY) if request_copy: diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_version.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_version.py index de39d939367f..f526d23db20e 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_version.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_version.py @@ -3,4 +3,4 @@ # Licensed under the MIT License. # ------------------------------------ -VERSION = "4.11.1" +VERSION = "4.11.2"