Skip to content

Commit 8938731

Browse files
committed
remove 'challenge' parameter from on_challenge (core)
1 parent 2f52480 commit 8938731

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

sdk/core/azure-core/azure/core/pipeline/policies/_authentication.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,19 @@ def send(self, request):
160160

161161
if response.http_response.status_code == 401:
162162
self._token = None # any cached token is invalid
163-
challenge = response.http_response.headers.get("WWW-Authenticate")
164-
if challenge and self.on_challenge(request, response, challenge):
163+
if "WWW-Authenticate" in response.http_response.headers and self.on_challenge(request, response):
165164
response = self.next.send(request)
166165

167166
return response
168167

169-
def on_challenge(self, request, response, challenge):
170-
# type: (PipelineRequest, PipelineResponse, str) -> bool
168+
def on_challenge(self, request, response):
169+
# type: (PipelineRequest, PipelineResponse) -> bool
171170
"""Authorize request according to an authentication challenge
172171
173172
This method is called when the resource provider responds 401 with a WWW-Authenticate header.
174173
175174
:param ~azure.core.pipeline.PipelineRequest request: the request which elicited an authentication challenge
176175
:param ~azure.core.pipeline.PipelineResponse response: the resource provider's response
177-
:param str challenge: response's WWW-Authenticate header, unparsed. It may contain multiple challenges.
178176
:returns: a bool indicating whether the policy should send the request
179177
"""
180178
# pylint:disable=unused-argument,no-self-use

sdk/core/azure-core/azure/core/pipeline/policies/_authentication_async.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,20 @@ async def send(self, request: "PipelineRequest") -> "PipelineResponse":
107107

108108
if response.http_response.status_code == 401:
109109
self._token = None # any cached token is invalid
110-
challenge = response.http_response.headers.get("WWW-Authenticate")
111-
if challenge:
112-
request_authorized = await self.on_challenge(request, response, challenge)
110+
if "WWW-Authenticate" in response.http_response.headers:
111+
request_authorized = await self.on_challenge(request, response)
113112
if request_authorized:
114113
response = await self.next.send(request)
115114

116115
return response
117116

118-
async def on_challenge(self, request: "PipelineRequest", response: "PipelineResponse", challenge: str) -> bool:
117+
async def on_challenge(self, request: "PipelineRequest", response: "PipelineResponse") -> bool:
119118
"""Authorize request according to an authentication challenge
120119
121120
This method is called when the resource provider responds 401 with a WWW-Authenticate header.
122121
123122
:param ~azure.core.pipeline.PipelineRequest request: the request which elicited an authentication challenge
124123
:param ~azure.core.pipeline.PipelineResponse response: the resource provider's response
125-
:param str challenge: response's WWW-Authenticate header, unparsed. It may contain multiple challenges.
126124
:returns: a bool indicating whether the policy should send the request
127125
"""
128126
# pylint:disable=unused-argument,no-self-use

0 commit comments

Comments
 (0)