Metadata-Version: 2.0
Name: pypac
Version: 0.2.1
Summary: Proxy auto-config and auto-discovery for Python.
Home-page: https://github.com/rbcarson/pypac
Author: Carson Lam
Author-email: carsonyylam@gmail.com
License: Apache 2.0
Keywords: pypac pac proxy autoconfig requests
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Requires-Dist: js2py (>=0.43)
Requires-Dist: requests (<3.0.0,>=2.0.0)
Requires-Dist: tld (>=0.7.3,<1.0.0)
Provides-Extra: socks
Requires-Dist: requests[socks] (>=2.10.0); extra == 'socks'

PyPAC: Proxy auto-config for Python
===================================

.. image:: https://img.shields.io/pypi/v/pypac.svg?maxAge=2592000
    :target: https://pypi.python.org/pypi/pypac
.. image:: https://img.shields.io/travis/rbcarson/pypac.svg?maxAge=2592000
    :target: https://travis-ci.org/rbcarson/pypac
.. image:: https://ci.appveyor.com/api/projects/status/y7nxvu2feu87i39t/branch/master?svg=true
    :target: https://ci.appveyor.com/project/rbcarson/pypac/branch/master
.. image:: https://img.shields.io/coveralls/rbcarson/pypac/HEAD.svg?maxAge=2592000
    :target: https://coveralls.io/github/rbcarson/pypac
.. image:: https://img.shields.io/codacy/grade/71ac103b491d44efb94976ca5ea5d89c.svg?maxAge=2592000
    :target: https://www.codacy.com/app/carsonyl/pypac

PyPAC is a pure-Python library for finding `proxy auto-config (PAC)`_ files and making HTTP requests
that respect them. PAC files are often used in organizations that need fine-grained and centralized control
of proxy settings. PyPAC supports Python 2.7 and 3.3+.

.. _proxy auto-config (PAC): https://en.wikipedia.org/wiki/Proxy_auto-config

PyPAC provides a subclass of a `Requests <http://docs.python-requests.org/en/master/>`_ ``Session``,
so you can start using it immediately, with any PAC file transparently discovered and honoured:

.. code-block:: python

    >>> from pypac import PACSession
    >>> session = PACSession()
    >>> session.get('http://example.org')
    ...

If a PAC file isn't found, then ``PACSession`` acts exactly like a regular ``Session``.

PyPAC can find PAC files according to the DNS portion of the `Web Proxy Auto-Discovery (WPAD)`_ protocol.
On Windows, PyPAC can also obtain the PAC file URL from the Internet Options dialog, via the registry.

.. _Web Proxy Auto-Discovery (WPAD): https://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol


Proxy authentication
--------------------

Basic proxy authentication can be specified in the PACSession constructor:

.. code-block:: python

    >>> from pypac import PACSession
    >>> from requests.auth import HTTPProxyAuth
    >>> session = PACSession(proxy_auth=HTTPProxyAuth('user', 'password'))
    >>> session.get('http://example.org')
    ...

To use NTLM authentication with proxies, install `requests-ntlm <https://github.com/requests/requests-ntlm>`_
and set ``PACSession.auth`` to an ``HttpNtlmAuth`` instance.


Security
--------

PAC files are JavaScript. PyPAC uses `Js2Py <https://github.com/PiotrDabkowski/Js2Py>`_
to parse and execute JavaScript. Js2Py was not designed for handling untrusted JavaScript,
and so it is unclear whether the handling of PAC files is sufficiently sandboxed to prevent
untrusted Python code execution.

When looking for a PAC file using DNS WPAD, the local machine's fully-qualified hostname is
checked against the `Mozilla Public Suffix List`_ to prevent requesting any PAC files outside
the scope of the organization. If the hostname's TLD isn't in the Public Suffix List, then
everything up to the final node is used in the search path. For example, a hostname of
foo.bar.local will result in a search for a PAC file from wpad.bar.local and wpad.local.

PyPAC uses the `tld <https://pypi.python.org/pypi/tld>`_ library to match TLDs.

.. _Mozilla Public Suffix List: https://publicsuffix.org/


What's missing
--------------

The DHCP portion of the Web Proxy Auto-Discovery (WPAD) protocol is not implemented.

PyPAC currently works with Requests by including a subclass of ``Session``.
No ready-to-use solutions are included for other HTTP libraries,
though PyPAC has all the building blocks needed to make one easily.

Pull requests to add these features are welcome.


History
=======

0.2.1 (2017-01-19)
------------------

- Require Js2Py >= 0.43 for Python 3.6 support, and to avoid needing to monkeypatch out ``pyimport``.


0.1.0 (2016-06-12)
------------------

- First release.


