Skip to content

[Bug] Cannot working if under retry #103

Open

Description

@Kenith

Hello,

The requests-ntlm is not working if the requets is under retry:

import requests
from requests.packages.urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
from requests_ntlm import HttpNtlmAuth

retries = Retry(total=1,
                read=1,
                connect=1,
                backoff_factor=1,
                status_forcelist=[500, 502, 503, 504, 407, 403, 401])

session = requests.Session()
session.verify = False
session.mount('http://', HTTPAdapter(max_retries=retries))
session.mount('https://', HTTPAdapter(max_retries=retries))

session.auth = HttpNtlmAuth('GLOBAL\\***', '***')
res = session.get('https://***.corp.***.com/owa/')

print res.status_code

Activity

  1. Kenith commented on Jan 4, 2018

    @Kenith
    Author

    Found the cause:

    because in my status_forcelist, there is: 401.
    I removed it, works.

    But why with the 401, the request-ntlm not working?

  2. jborean93 commented on Jan 7, 2018

    @jborean93
    Contributor

    Probably because NTLM authentication relies on receiving 401 responses. It works like

    • Send un authenticated request
    • Receive 401 response with header that lists supported auth mechanisms
    • Send NTLM negotiate message
    • Receive 401 response with NTLM challenge message
    • Send NTLM authenticate message
    • Receive 200 response as user is now authenticated.

    I don't know how the Retry operations change the behaviour but it could be that it adds a hook to 401 responses and continues to try and send the same message (retry) without any of the NTLM messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions