Skip to content

Commit

Permalink
Update requests_ntlm/requests_ntlm.py
Browse files Browse the repository at this point in the history
Co-authored-by: Jordan Borean <[email protected]>
  • Loading branch information
AdrianVollmer and jborean93 authored Oct 17, 2023
1 parent 670e1a5 commit 1ab7e2d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions requests_ntlm/requests_ntlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,17 @@ def retry_using_http_NTLM_auth(

auth_strip = auth_type + " "

challenges = [
s
for s in (val.lstrip() for val in auth_header_value.split(","))
if s.startswith(auth_strip)
]

if not challenges:
raise AccessDenied("Access denied")

ntlm_header_value = next(
challenges
(
s
for s in (val.lstrip() for val in auth_header_value.split(","))
if s.startswith(auth_strip)
),
None
).strip()

if not ntlm_header_value:
raise PermissionError("Access denied: Server did not respond with NTLM challenge token")

# Parse the challenge in the ntlm context and perform
# the second step of authentication
Expand Down

0 comments on commit 1ab7e2d

Please sign in to comment.