
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
requests-ntlm3, which is based on requests-ntlm, allows for HTTP NTLM authentication using the requests library.
pip install requests-ntlm3
HttpNtlmAuth
extends requests AuthBase
, so usage is simple:
import requests
from requests_ntlm3 import HttpNtlmAuth
auth=HttpNtlmAuth('domain\\username','password')
requests.get("http://ntlm_protected_site.com", auth=auth)
See this MS doc on LM compatibility levels. requests_ntlm3
defaults to
compatibility level 3 which supports NTLMv2 [only]. You can change the compatibility level as follows:
import requests
from requests_ntlm3 import HttpNtlmAuth, NtlmCompatibility
username = 'domain\\username'
password = 'password123'
ntlm_compatibility = NtlmCompatibility.LM_AND_NTLMv1_WITH_ESS # => level 1
auth=HttpNtlmAuth(username, password, ntlm_compatibility=ntlm_compatibility)
requests.get("http://ntlm_protected_site.com", auth=auth)
HttpNtlmAuth
can be used in conjunction with a Session
in order to
make use of connection pooling. Since NTLM authenticates connections,
this is more efficient. Otherwise, each request will go through a new
NTLM challenge-response.
import requests
from requests_ntlm3 import HttpNtlmAuth
session = requests.Session()
session.auth = HttpNtlmAuth('domain\\username','password')
session.get('http://ntlm_protected_site.com')
When using requests-ntlm3
to create SSL proxy tunnel via
HTTP CONNECT, the so-called
"NTLM Dance" - ie, the NTLM authentication handshake - has to be done at the lower level
(at httplib
level) at tunnel-creation step. This means that you should use the HttpNtlmAdapter
and requests session. This HttpNtlmAdapter
is responsible for sending proxy auth information
downstream.
Here is a basic example:
import requests
from requests_ntlm3 import (
HttpNtlmAuth,
HttpNtlmAdapter,
NtlmCompatibility
)
username = '...'
password = '...'
proxy_ip = '...'
proxy_port = '...'
proxies = {
'http': 'http://{}:{}'.format(proxy_ip, proxy_port),
'https': 'http://{}:{}'.format(proxy_ip, proxy_port)
}
ntlm_compatibility = NtlmCompatibility.NTLMv2_DEFAULT
session = requests.Session()
session.mount(
'https://',
HttpNtlmAdapter(
username,
password,
ntlm_compatibility=ntlm_compatibility
)
)
session.mount(
'http://',
HttpNtlmAdapter(
username,
password,
ntlm_compatibility=ntlm_compatibility
)
)
session.auth = HttpNtlmAuth(
username,
password,
ntlm_compatibility=ntlm_compatibility
)
session.proxies = proxies
response = session.get('http:/foobar.com')
FAQs
The HTTP NTLM proxy and/or server authentication library.
We found that requests-ntlm3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.