Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/requests_toolbelt/auth/ |
| [Home] [System Details] [Kill Me] |
�
ӵ
Yc@sbdZddlmZmZddlmZmZdefd��YZdefd��YZdS( s�
requests_toolbelt.auth.handler
==============================
This holds all of the implementation details of the Authentication Handler.
i����(tAuthBaset
HTTPBasicAuth(turlparset
urlunparsetAuthHandlercBs\eZdZd�Zd�Zd�Zd�Zed��Zd�Z d�Z
d�ZRS( s�
The ``AuthHandler`` object takes a dictionary of domains paired with
authentication strategies and will use this to determine which
credentials
to use when making a request. For example, you could do the following:
.. code-block:: python
from requests import HTTPDigestAuth
from requests_toolbelt.auth.handler import AuthHandler
import requests
auth = AuthHandler({
'https://api.github.com': ('sigmavirus24',
'fakepassword'),
'https://example.com':
HTTPDigestAuth('username', 'password')
})
r = requests.get('https://api.github.com/user',
auth=auth)
# => <Response [200]>
r = requests.get('https://example.com/some/path',
auth=auth)
# => <Response [200]>
s = requests.Session()
s.auth = auth
r = s.get('https://api.github.com/user')
# => <Response [200]>
.. warning::
:class:`requests.auth.HTTPDigestAuth` is not yet thread-safe. If
you
use :class:`AuthHandler` across multiple threads you should
instantiate a new AuthHandler for each thread with a new
HTTPDigestAuth instance for each thread.
cCst|�|_|j�dS(N(tdictt
strategiest
_make_uniform(tselfR((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyt__init__6scCs|j|j�}||�S(N(tget_strategy_forturl(Rtrequesttauth((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyt__call__:scCsdj|j�S(Ns<AuthHandler({0!r})>(tformatR(R((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyt__repr__>scCsIt|jj��}i|_x$|D]\}}|j||�q%WdS(N(tlistRtitemstadd_strategy(Rtexisting_strategiestktv((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyRAs cCs:t|�}t|jj�|jj�ddddf�S(Nt(RRtschemetlowertnetloc(Rtparsed((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyt
_key_from_urlHscCs>t|t�rt|�}n|j|�}||j|<dS(sAdd
a new domain and authentication strategy.
:param str domain: The domain you wish to match against. For
example:
``'https://api.github.com'``
:param str strategy: The authentication strategy you wish to use
for
that domain. For example: ``('username',
'password')`` or
``requests.HTTPDigestAuth('username',
'password')``
.. code-block:: python
a = AuthHandler({})
a.add_strategy('https://api.github.com',
('username', 'password'))
N(t
isinstancettupleRRR(Rtdomaintstrategytkey((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyROscCs%|j|�}|jj|t��S(sRetrieve
the authentication strategy for a specified URL.
:param str url: The full URL you will be making a request against.
For
example, ``'https://api.github.com/user'``
:returns: Callable that adds authentication to a request.
.. code-block:: python
import requests
a = AuthHandler({'example.com', ('foo',
'bar')})
strategy =
a.get_strategy_for('http://example.com/example')
assert isinstance(strategy, requests.auth.HTTPBasicAuth)
(RRtgettNullAuthStrategy(RRR!((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyR
escCs/|j|�}||jkr+|j|=ndS(skRemove the domain and
strategy from the collection of strategies.
:param str domain: The domain you wish remove. For example,
``'https://api.github.com'``.
.. code-block:: python
a = AuthHandler({'example.com', ('foo',
'bar')})
a.remove_strategy('example.com')
assert a.strategies == {}
N(RR(RRR!((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pytremove_strategyws
(t__name__t
__module__t__doc__R RRRtstaticmethodRRR
R$(((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyRs% R#cBseZd�Zd�ZRS(cCsdS(Ns<NullAuthStrategy>((R((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyR�scCs|S(N((Rtr((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyR�s(R%R&RR(((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyR#�s N( R't
requests.authRRtrequests.compatRRRR#(((sB/usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyt<module> sz