requests-ntlm2


Namerequests-ntlm2 JSON
Version 6.5.3 PyPI version JSON
download
home_pagehttps://github.com/dopstar/requests-ntlm2
SummaryThe HTTP NTLM proxy and/or server authentication library.
upload_time2023-08-01 14:47:03
maintainer
docs_urlNone
authorMkhanyisi Madlavana
requires_python
licenseISC
keywords ntlm requests proxy authorization ntlm dance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <h1 align="center">requests-ntlm2</h1>
<div align="center">NTLM authentication plugin for Requests</div>
<br />

[![Build Status](https://github.com/dopstar/requests-ntlm2/workflows/build/badge.svg?branch=master)](https://github.com/dopstar/requests-ntlm2/actions?query=workflow%3Abuild)
[![codecov](https://codecov.io/gh/dopstar/requests-ntlm2/branch/master/graph/badge.svg)](https://codecov.io/gh/dopstar/requests-ntlm2)
[![Python Version](https://img.shields.io/pypi/pyversions/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)
[![PyPI Status](https://img.shields.io/pypi/v/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)
[![Downloads](https://img.shields.io/pypi/dm/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)
[![Licence](https://img.shields.io/github/license/dopstar/requests-ntlm2.svg)](https://raw.githubusercontent.com/dopstar/requests-ntlm2/master/LICENSE)
[![Code Style: Black](https://img.shields.io/badge/code%20style-black-101010.svg)](https://github.com/psf/black)

requests-ntlm2, which is based on [requests-ntlm](https://github.com/requests/requests-ntlm), allows for HTTP NTLM authentication using the requests library.

## Installation

```shell
pip install requests-ntlm2
```

## Usage

### Basic Usage
`HttpNtlmAuth` extends requests `AuthBase`, so usage is simple:

```python
import requests
from requests_ntlm2 import HttpNtlmAuth

auth=HttpNtlmAuth('domain\\username','password')
requests.get("http://ntlm_protected_site.com", auth=auth)
```
___

### Changing NTLM compatibility level
See this [MS doc](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/cc960646%28v=technet.10%29) on LM compatibility levels. `requests_ntlm2` defaults to
compatibility level 3 which supports NTLMv2 [only]. You can change the compatibility level as follows:


```python
import requests
from requests_ntlm2 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)
```
___

### Using with Requests Session
`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.

```python
import requests
from requests_ntlm2 import HttpNtlmAuth

session = requests.Session()
session.auth = HttpNtlmAuth('domain\\username','password')
session.get('http://ntlm_protected_site.com')
```
___

### HTTP CONNECT Usage
When using `requests-ntlm2` to create SSL proxy tunnel via
[HTTP CONNECT](https://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_method), 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:

```python
import requests
from requests_ntlm2 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')
```

## Requirements

- [requests](https://github.com/kennethreitz/requests/)
- [ntlm-auth](https://github.com/jborean93/ntlm-auth)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dopstar/requests-ntlm2",
    "name": "requests-ntlm2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "NTLM,requests,proxy,authorization,NTLM dance",
    "author": "Mkhanyisi Madlavana",
    "author_email": "mmadlavana@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3e/ea/931ef1cfa9381d4ab8aa7ebfae5c851ecdaf87593e516c79e5626ffb962e/requests_ntlm2-6.5.3.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">requests-ntlm2</h1>\n<div align=\"center\">NTLM authentication plugin for Requests</div>\n<br />\n\n[![Build Status](https://github.com/dopstar/requests-ntlm2/workflows/build/badge.svg?branch=master)](https://github.com/dopstar/requests-ntlm2/actions?query=workflow%3Abuild)\n[![codecov](https://codecov.io/gh/dopstar/requests-ntlm2/branch/master/graph/badge.svg)](https://codecov.io/gh/dopstar/requests-ntlm2)\n[![Python Version](https://img.shields.io/pypi/pyversions/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)\n[![PyPI Status](https://img.shields.io/pypi/v/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)\n[![Downloads](https://img.shields.io/pypi/dm/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)\n[![Licence](https://img.shields.io/github/license/dopstar/requests-ntlm2.svg)](https://raw.githubusercontent.com/dopstar/requests-ntlm2/master/LICENSE)\n[![Code Style: Black](https://img.shields.io/badge/code%20style-black-101010.svg)](https://github.com/psf/black)\n\nrequests-ntlm2, which is based on [requests-ntlm](https://github.com/requests/requests-ntlm), allows for HTTP NTLM authentication using the requests library.\n\n## Installation\n\n```shell\npip install requests-ntlm2\n```\n\n## Usage\n\n### Basic Usage\n`HttpNtlmAuth` extends requests `AuthBase`, so usage is simple:\n\n```python\nimport requests\nfrom requests_ntlm2 import HttpNtlmAuth\n\nauth=HttpNtlmAuth('domain\\\\username','password')\nrequests.get(\"http://ntlm_protected_site.com\", auth=auth)\n```\n___\n\n### Changing NTLM compatibility level\nSee this [MS doc](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/cc960646%28v=technet.10%29) on LM compatibility levels. `requests_ntlm2` defaults to\ncompatibility level 3 which supports NTLMv2 [only]. You can change the compatibility level as follows:\n\n\n```python\nimport requests\nfrom requests_ntlm2 import HttpNtlmAuth, NtlmCompatibility\n\nusername = 'domain\\\\username'\npassword = 'password123'\nntlm_compatibility = NtlmCompatibility.LM_AND_NTLMv1_WITH_ESS  # => level 1\nauth=HttpNtlmAuth(username, password, ntlm_compatibility=ntlm_compatibility)\n\nrequests.get(\"http://ntlm_protected_site.com\", auth=auth)\n```\n___\n\n### Using with Requests Session\n`HttpNtlmAuth` can be used in conjunction with a `Session` in order to\nmake use of connection pooling. Since NTLM authenticates connections,\nthis is more efficient. Otherwise, each request will go through a new\nNTLM challenge-response.\n\n```python\nimport requests\nfrom requests_ntlm2 import HttpNtlmAuth\n\nsession = requests.Session()\nsession.auth = HttpNtlmAuth('domain\\\\username','password')\nsession.get('http://ntlm_protected_site.com')\n```\n___\n\n### HTTP CONNECT Usage\nWhen using `requests-ntlm2` to create SSL proxy tunnel via\n[HTTP CONNECT](https://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_method), the so-called\n\"NTLM Dance\" - ie, the NTLM authentication handshake - has to be done at the lower level\n(at `httplib` level) at tunnel-creation step. This means that you should use the `HttpNtlmAdapter`\nand requests session. This `HttpNtlmAdapter` is responsible for sending proxy auth information\ndownstream. \n\nHere is a basic example:\n\n```python\nimport requests\nfrom requests_ntlm2 import (\n    HttpNtlmAuth,\n    HttpNtlmAdapter,\n    NtlmCompatibility\n)\n\nusername = '...'\npassword = '...'\nproxy_ip = '...'\nproxy_port = '...'\n\nproxies = {\n    'http': 'http://{}:{}'.format(proxy_ip, proxy_port),\n    'https': 'http://{}:{}'.format(proxy_ip, proxy_port)\n}\n\nntlm_compatibility = NtlmCompatibility.NTLMv2_DEFAULT\n\nsession = requests.Session()\nsession.mount(\n    'https://',\n    HttpNtlmAdapter(\n        username,\n        password,\n        ntlm_compatibility=ntlm_compatibility\n    )\n)\nsession.mount(\n    'http://',\n    HttpNtlmAdapter(\n        username,\n        password,\n        ntlm_compatibility=ntlm_compatibility\n    )\n)\nsession.auth = HttpNtlmAuth(\n    username,\n    password,\n    ntlm_compatibility=ntlm_compatibility\n)\nsession.proxies = proxies\n\nresponse = session.get('http:/foobar.com')\n```\n\n## Requirements\n\n- [requests](https://github.com/kennethreitz/requests/)\n- [ntlm-auth](https://github.com/jborean93/ntlm-auth)\n\n\n",
    "bugtrack_url": null,
    "license": "ISC",
    "summary": "The HTTP NTLM proxy and/or server authentication library.",
    "version": "6.5.3",
    "project_urls": {
        "Documentation": "https://dopstar.github.io/requests-ntlm2",
        "Download": "https://github.com/dopstar/requests-ntlm2/archive/6.5.3.tar.gz",
        "Homepage": "https://github.com/dopstar/requests-ntlm2",
        "Source": "https://github.com/dopstar/requests-ntlm2",
        "Tracker": "https://github.com/dopstar/requests-ntlm2/issues"
    },
    "split_keywords": [
        "ntlm",
        "requests",
        "proxy",
        "authorization",
        "ntlm dance"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7985a43decb5b322c8a2dad3f93013833118a52adc58cf824584bc7837eb99ab",
                "md5": "2e22f9bdb55a7ab0ccecacf60792b986",
                "sha256": "c0b405f6b683082eb57ae12f304ce111a66b8a747894512f19d823db9ab3e53e"
            },
            "downloads": -1,
            "filename": "requests_ntlm2-6.5.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2e22f9bdb55a7ab0ccecacf60792b986",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 14263,
            "upload_time": "2023-08-01T14:47:01",
            "upload_time_iso_8601": "2023-08-01T14:47:01.947658Z",
            "url": "https://files.pythonhosted.org/packages/79/85/a43decb5b322c8a2dad3f93013833118a52adc58cf824584bc7837eb99ab/requests_ntlm2-6.5.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3eea931ef1cfa9381d4ab8aa7ebfae5c851ecdaf87593e516c79e5626ffb962e",
                "md5": "c5713c28860c03ee0a1ac45c3b3db145",
                "sha256": "2785ff185ab3163d0755f48676cf20e41481fda8318d5921a790ec7bd08c28fe"
            },
            "downloads": -1,
            "filename": "requests_ntlm2-6.5.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c5713c28860c03ee0a1ac45c3b3db145",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13767,
            "upload_time": "2023-08-01T14:47:03",
            "upload_time_iso_8601": "2023-08-01T14:47:03.600687Z",
            "url": "https://files.pythonhosted.org/packages/3e/ea/931ef1cfa9381d4ab8aa7ebfae5c851ecdaf87593e516c79e5626ffb962e/requests_ntlm2-6.5.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-01 14:47:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dopstar",
    "github_project": "requests-ntlm2",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "requests-ntlm2"
}
        
Elapsed time: 0.09426s