§
    sŠtj7  ã                   ób   — d Z ddlmZmZ ddlmZmZ  G d„ de¦  «        Z G d„ de¦  «        ZdS )	zŽ

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

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

é    )ÚAuthBaseÚHTTPBasicAuth)ÚurlparseÚ
urlunparsec                   óR   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zed„ ¦   «         Z	d„ Z
d„ Zd	„ Zd
S )ÚAuthHandlera¦  

    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                 óV   — t          |¦  «        | _        |                      ¦   «          d S ©N)ÚdictÚ
strategiesÚ_make_uniform)Úselfr   s     ú\/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/requests_toolbelt/auth/handler.pyÚ__init__zAuthHandler.__init__6   s)   € Ý˜zÑ*Ô*ˆŒØ×ÒÑÔÐÐÐó    c                 óL   — |                       |j        ¦  «        } ||¦  «        S r
   )Úget_strategy_forÚurl)r   ÚrequestÚauths      r   Ú__call__zAuthHandler.__call__:   s%   € Ø×$Ò$ W¤[Ñ1Ô1ˆØˆt�G‰}Œ}Ðr   c                 ó6   — d                      | j        ¦  «        S )Nz<AuthHandler({!r})>)Úformatr   ©r   s    r   Ú__repr__zAuthHandler.__repr__>   s   € Ø$×+Ò+¨D¬OÑ<Ô<Ð<r   c                 óœ   — t          | j                             ¦   «         ¦  «        }i | _        |D ]\  }}|                      ||¦  «         Œd S r
   )Úlistr   ÚitemsÚadd_strategy)r   Úexisting_strategiesÚkÚvs       r   r   zAuthHandler._make_uniformA   s[   € Ý" 4¤?×#8Ò#8Ñ#:Ô#:Ñ;Ô;ÐØˆŒà)ð 	$ð 	$‰FˆQ�Ø×Ò˜a Ñ#Ô#Ð#Ð#ð	$ð 	$r   c                 ó¦   — t          | ¦  «        }t          |j                             ¦   «         |j                             ¦   «         ddddf¦  «        S )NÚ )r   r   ÚschemeÚlowerÚnetloc)r   Úparseds     r   Ú_key_from_urlzAuthHandler._key_from_urlH   sN   € å˜#‘”ˆÝ˜6œ=×.Ò.Ñ0Ô0Ø!œ=×.Ò.Ñ0Ô0Ø˜r 2 rð+ñ ,ô ,ð 	,r   c                 ó€   — t          |t          ¦  «        r	t          |Ž }|                      |¦  «        }|| j        |<   dS )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   zAuthHandler.add_strategyO   sE   € õ  �h¥Ñ&Ô&ð 	0Ý$ hÐ/ˆHà× Ò  Ñ(Ô(ˆØ'ˆŒ˜ÑÐÐr   c                 óz   — |                       |¦  «        }| j                             |t          ¦   «         ¦  «        S )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   r/   s      r   r   zAuthHandler.get_strategy_fore   s6   € ð × Ò  Ñ%Ô%ˆØŒ×"Ò" 3Õ(8Ñ(:Ô(:Ñ;Ô;Ð;r   c                 óV   — |                       |¦  «        }|| j        v r
| j        |= dS dS )ak  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   r-   r/   s      r   Úremove_strategyzAuthHandler.remove_strategyw   s<   € ð × Ò  Ñ(Ô(ˆØ�$”/Ð!Ð!Ø” Ð$Ð$Ð$ð "Ð!r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ústaticmethodr)   r   r   r4   © r   r   r   r      s£   € € € € € ð#ð #ðJð ð ðð ð ð=ð =ð =ð$ð $ð $ð ð,ð ,ñ „\ð,ð(ð (ð (ð,<ð <ð <ð$%ð %ð %ð %ð %r   r   c                   ó   — e Zd Zd„ Zd„ ZdS )r2   c                 ó   — dS )Nz<NullAuthStrategy>r:   r   s    r   r   zNullAuthStrategy.__repr__Š   s   € Ø#Ð#r   c                 ó   — |S r
   r:   )r   Úrs     r   r   zNullAuthStrategy.__call__�   s   € Øˆr   N)r5   r6   r7   r   r   r:   r   r   r2   r2   ‰   s2   € € € € € ð$ð $ð $ðð ð ð ð r   r2   N)	r8   Úrequests.authr   r   Úrequests.compatr   r   r   r2   r:   r   r   ú<module>rA      s¨   ððð ð 2Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0ðw%ð w%ð w%ð w%ð w%�(ñ w%ô w%ð w%ðtð ð ð ð �xñ ô ð ð ð r   