ó
    úÞ j7  ã                   óT   • S r SSKJrJr  SSKJrJr   " S S\5      r " S S\5      rg)	zŽ

requests_toolbelt.auth.handler
==============================

This holds all of the implementation details of the Authentication Handler.

é    )ÚAuthBaseÚHTTPBasicAuth)ÚurlparseÚ
urlunparsec                   óR   • \ rS rSrSrS rS rS rS r\	S 5       r
S rS	 rS
 rSrg)ÚAuthHandleré   aB  

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.

c                 óD   • [        U5      U l        U R                  5         g ©N)ÚdictÚ
strategiesÚ_make_uniform)Úselfr   s     ÚX/var/www/html/gaurav/venv/lib/python3.13/site-packages/requests_toolbelt/auth/handler.pyÚ__init__ÚAuthHandler.__init__6   s   € Ü˜zÓ*ˆŒØ×ÑÕó    c                 óH   • U R                  UR                  5      nU" U5      $ r   )Úget_strategy_forÚurl)r   ÚrequestÚauths      r   Ú__call__ÚAuthHandler.__call__:   s    € Ø×$Ñ$ W§[¡[Ó1ˆÙ�G‹}Ðr   c                 ó8   • SR                  U R                  5      $ )Nz<AuthHandler({!r})>)Úformatr   ©r   s    r   Ú__repr__ÚAuthHandler.__repr__>   s   € Ø$×+Ñ+¨D¯O©OÓ<Ð<r   c                 ó�   • [        U R                  R                  5       5      n0 U l        U H  u  p#U R                  X#5        M     g r   )Úlistr   ÚitemsÚadd_strategy)r   Úexisting_strategiesÚkÚvs       r   r   ÚAuthHandler._make_uniformA   s;   € Ü" 4§?¡?×#8Ñ#8Ó#:Ó;ÐØˆŒã)‰FˆQØ×Ñ˜aÖ#ò *r   c                 óš   • [        U 5      n[        UR                  R                  5       UR                  R                  5       SSSS45      $ )NÚ )r   r   ÚschemeÚlowerÚnetloc)r   Úparseds     r   Ú_key_from_urlÚAuthHandler._key_from_urlH   sE   € ä˜#“ˆÜ˜6Ÿ=™=×.Ñ.Ó0Ø!Ÿ=™=×.Ñ.Ó0Ø˜r 2 rð+ó ,ð 	,r   c                 ó|   • [        U[        5      (       a  [        U6 nU R                  U5      nX R                  U'   g)aÊ  Add 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)Ú
isinstanceÚtupler   r.   r   )r   ÚdomainÚstrategyÚkeys       r   r#   ÚAuthHandler.add_strategyO   s7   € ô  �h¤×&Ñ&Ü$ hÐ/ˆHà× Ñ  Ó(ˆØ'�‰˜Òr   c                 ól   • U R                  U5      nU R                  R                  U[        5       5      $ )aË  Retrieve 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)

)r.   r   ÚgetÚNullAuthStrategy)r   r   r5   s      r   r   ÚAuthHandler.get_strategy_fore   s/   € ð × Ñ  Ó%ˆØ�‰×"Ñ" 3Ô(8Ó(:Ó;Ð;r   c                 ó`   • U R                  U5      nX R                  ;   a  U R                  U	 gg)a3  Remove 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)r.   r   )r   r3   r5   s      r   Úremove_strategyÚAuthHandler.remove_strategyw   s/   € ð × Ñ  Ó(ˆØ—/‘/Ó!Ø—‘ Ñ$ð "r   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r   Ústaticmethodr.   r#   r   r<   Ú__static_attributes__© r   r   r   r      s?   † ñ#òJòò=ò$ð ñ,ó ð,ò(ò,<õ$%r   r   c                   ó    • \ rS rSrS rS rSrg)r9   é‰   c                 ó   • g)Nz<NullAuthStrategy>rE   r   s    r   r   ÚNullAuthStrategy.__repr__Š   s   € Ø#r   c                 ó   • U$ r   rE   )r   Úrs     r   r   ÚNullAuthStrategy.__call__�   s   € Øˆr   rE   N)r>   r?   r@   rA   r   r   rD   rE   r   r   r9   r9   ‰   s   † ò$õr   r9   N)	rB   Úrequests.authr   r   Úrequests.compatr   r   r   r9   rE   r   r   Ú<module>rO      s-   ðñ÷ 2ß 0ôw%�(ô w%ôt�xõ r   