Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pip/_internal/network/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pip/_internal/network/__pycache__/auth.cpython-312.pyc

�

4ΜgIQ���dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZddlmZddlmZmZmZmZmZmZddlmZmZdd	lmZmZdd
lmZddl m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'dd
l(m)Z)e!e*�Z+da,Gd�de�Z-Gd�de
�Z.Gd�de.�Z/Gd�de.�Z0Gd�de.�Z1e
d��de2de.fd��Z3Gd�de�Z4y)z�Network Authentication Helpers

Contains interface (MultiDomainBasicAuth) and associated glue code for
providing credentials in the context of network requests.
�N)�ABC�abstractmethod)�	lru_cache)�commonprefix)�Path)�Any�Dict�List�
NamedTuple�Optional�Tuple)�AuthBase�
HTTPBasicAuth)�Request�Response)�get_netrc_auth)�	getLogger)�ask�	ask_input�ask_password�remove_auth_from_url�split_auth_netloc_from_url)�AuthInfoFc�,�eZdZUeed<eed<eed<y)�Credentials�url�username�passwordN)�__name__�
__module__�__qualname__�str�__annotations__���E/usr/local/lib/python3.12/site-packages/pip/_internal/network/auth.pyrr's��	�H��M��Mr%rc	�h�eZdZUdZeed<ededeedee	fd��Z
ededededdfd	��Zy)
�KeyRingBaseProviderzKeyring base provider interface�has_keyringrr�returnc��y�Nr$��selfrrs   r&�
get_auth_infoz!KeyRingBaseProvider.get_auth_info2s��!r%rNc��yr,r$�r.rrrs    r&�save_auth_infoz"KeyRingBaseProvider.save_auth_info7s��NQr%)rr r!�__doc__�boolr#rr"rrr/r2r$r%r&r(r(-sb��)����!��!�"*�3�-�!�	�(�	�!��!��Q�#�Q��Q��Q��Q��Qr%r(c�L�eZdZdZdZdedeedeefd�Zdedededdfd	�Z	y)
�KeyRingNullProviderzKeyring null providerFrrr*c��yr,r$r-s   r&r/z!KeyRingNullProvider.get_auth_info@���r%rNc��yr,r$r1s    r&r2z"KeyRingNullProvider.save_auth_infoCr8r%)
rr r!r3r)r"rrr/r2r$r%r&r6r6;sN����K������
��(�8�BT���#�������r%r6c�T�eZdZdZdZdd�Zdedeedeefd�Z	deded	eddfd
�Z
y)�KeyRingPythonProviderz7Keyring interface which uses locally imported `keyring`Tr*Nc��ddl}||_y)Nr��keyring)r.r>s  r&�__init__zKeyRingPythonProvider.__init__Ls�����r%rrc�>�t|jd�rMtjd|�|jj	||�}|�|j
|jfSy|�8tjd|�|jj||�}|r||fSy)N�get_credentialz'Getting credentials from keyring for %sz$Getting password from keyring for %s)�hasattrr>�logger�debugrArr�get_password)r.rr�credrs     r&r/z#KeyRingPythonProvider.get_auth_infoQs����4�<�<�!1�2��L�L�B�C�H��<�<�.�.�s�H�=�D����}�}�d�m�m�3�3�����L�L�?��E��|�|�0�0��h�?�H����)�)�r%rc�>�|jj|||�yr,)r>�set_passwordr1s    r&r2z$KeyRingPythonProvider.save_auth_infocs�����!�!�#�x��:r%)r*N)rr r!r3r)r?r"rrr/r2r$r%r&r;r;GsS��A��K��
�����
��(�8�BT��$;�#�;��;��;��;r%r;c��eZdZdZdZdeddfd�Zdedeedeefd	�Z	deded
eddfd�Z
dededeefd
�Zdeded
eddfd�Zy)�KeyRingCliProviderz�Provider which uses `keyring` cli

    Instead of calling the keyring package installed alongside pip
    we call keyring on the command line which will enable pip to
    use which ever installation of keyring is available first in
    PATH.
    T�cmdr*Nc��||_yr,r=)r.rKs  r&r?zKeyRingCliProvider.__init__rs	����r%rrc�8�|�|j||�}|�||fSyr,)�
_get_passwordr1s    r&r/z KeyRingCliProvider.get_auth_infous0�����)�)�#�x�8�H��#���)�)�r%rc�(�|j|||�Sr,)�
_set_passwordr1s    r&r2z!KeyRingCliProvider.save_auth_info~s���!�!�#�x��:�:r%�service_namec�v�|j�y|jd||g}tjj�}d|d<t	j
|tjtj|��}|jry|jjd�jtj�S)z;Mirror the implementation of keyring.get_password using cliN�get�utf-8�PYTHONIOENCODING)�stdin�stdout�env)
r>�os�environ�copy�
subprocess�run�DEVNULL�PIPE�
returncoderW�decode�strip�linesep)r.rQrrKrX�ress      r&rNz KeyRingCliProvider._get_password�s����<�<����|�|�U�L�(�;���j�j�o�o���")�����n�n���$�$��?�?��	
���>�>���z�z� � ��)�/�/��
�
�;�;r%c���|j�ytjj�}d|d<t	j
|jd||g|�tj��j�|d��y)z;Mirror the implementation of keyring.set_password using cliNrTrU�setT)�inputrX�check)r>rYrZr[r\r]rc�encode)r.rQrrrXs     r&rPz KeyRingCliProvider._set_password�sj���<�<����j�j�o�o���")�������
�\�\�5�,��9��J�r�z�z�l�+�2�2�4���		
�r%)
rr r!r3r)r"r?rrr/r2rNrPr$r%r&rJrJgs�����K��C��D�������
��(�8�BT��;�#�;��;��;��;�<�#�<��<��#��<�$�#������PT�r%rJ)�maxsize�providerr*c��tjd|�trd}|dvr"	t�}tjd�|S|d	v�r(tjd
�}|r�|jtjd��r�tj dt"fd
��}t%tjd��}g}|�j't(j*�D]0}t%|�}		|	j-|�s|j/|��2t(j*j3|�}tjd
|��}|r!tjd|�t5|�Stjd�t7�S#t$rY��Xt
$rP}d}|dk(r|dz}tj
||tjtj���Yd}~���d}~wwxYw#t0$rY��wxYw)NzKeyring provider requested: %s�disabled)�import�autozKeyring provider set: importz1Installed copy of keyring fails with exception %sroz3, trying to find a keyring executable as a fallback��exc_info)r\ror>�scriptsr*c���tjjdd�}|�	tjd�}|S|S#tt
f$rtj}Y|SwxYw)N�PATH�CS_PATH)rYrZrS�confstr�AttributeError�
ValueError�defpath��paths r&�"PATH_as_shutil_which_determines_itz@get_keyring_provider.<locals>.PATH_as_shutil_which_determines_it�s_���z�z�~�~�f�d�3���<�*�!�z�z�)�4����t���
+�J�7�*�!�z�z����
*�s�=�A �A rzz3Keyring provider set: subprocess with executable %szKeyring provider set: disabled)rC�verbose�KEYRING_DISABLEDr;�ImportError�	Exception�warning�isEnabledFor�logging�DEBUG�shutil�which�
startswith�	sysconfig�get_path�typing�
no_type_checkr"r�splitrY�pathsep�samefile�append�FileNotFoundError�joinrJr6)
rk�impl�exc�msg�clir|rr�pathsr{�ps
          r&�get_keyring_providerr��s���
�N�N�3�X�>�����%�%�	R�(�*�D��N�N�9�:��K��)�)��l�l�9�%���3�>�>�)�"4�"4�Y�"?�@�
�
!�
!�
��
�"�
��9�-�-�i�8�9�G��E�:�<�B�B�2�:�:�N����J����:�:�g�.����T�*��	O��:�:�?�?�5�)�D��,�,�y�t�4�C���N�N�P�RU�V�%�c�*�*�
�N�N�3�4�� � ��_�	���	R�F�C��6�!��Q�Q���N�N�3��f�.A�.A�'�-�-�.P�N�Q�Q��
	R��B)����s0� F�5"G8�	G5�G5�%AG0�0G5�8	H�Hc	��eZdZ			d!dedeeededdfd�Zede	fd��Z
e
jd	eddfd
��Z
edefd��Zdeed
eedee
fd�Zdedeefd�Zddd�dededede
fd�Zdedeeeeeeffd�Zdedefd�Zdedeeeeeeffd�Zdefd�Zdededefd�Zdededdfd�Zdededdfd �Zy)"�MultiDomainBasicAuthTN�	prompting�
index_urls�keyring_providerr*c�J�||_||_||_i|_d|_yr,)r�r�r��	passwords�_credentials_to_save)r.r�r�r�s    r&r?zMultiDomainBasicAuth.__init__�s,��#���$��� 0���.0���<@��!r%c�,�t|j�Sr,)r��_keyring_provider�r.s r&r�z%MultiDomainBasicAuth.keyring_provider�s��#�D�$:�$:�;�;r%rkc��||_yr,)r�)r.rks  r&r�z%MultiDomainBasicAuth.keyring_provider�s��"*��r%c�:�|jxs|jdvS)N)rorm)r�r�r�s r&�use_keyringz MultiDomainBasicAuth.use_keyring�s��
�~�~�S��!7�!7�?S�!S�Sr%rrc��|sy	|jj||�S#t$rV}tj	dd��tjdt
|��datj�Yd}~yd}~wwxYw)z3Return the tuple auth for a given url from keyring.Nz&Keyring is skipped due to an exceptionTrpz*Keyring is skipped due to an exception: %s)
r�r/r�rCrDr�r"r~r��cache_clear)r.rrr�s    r&�_get_keyring_authz&MultiDomainBasicAuth._get_keyring_authsx����	��(�(�6�6�s�H�E�E���	�
�L�L�A�D�L�Q��N�N�<��C��
�
 $�� �,�,�.���	�s�!�	B�AA;�;Bc�T��|r|jsyt|�jd�dz}tjj|��g}|jD]�}|jd�dz}tjjt|��}�|k(r|cS�j|jk7r�btjj|�}|j|���|sy|jd�fd���tjj|d�S)a�Return the original index URL matching the requested URL.

        Cached or dynamically generated credentials may work against
        the original index URL rather than just the netloc.

        The provided url should have had its username and password
        removed already. If the original index url had credentials then
        they will be included in the return value.

        Returns None if no matching index was found, or if --no-index
        was specified by the user.
        N�/Tc�d��t�j|jg�jd�S)Nr�)rr{�rfind)�	candidate�
parsed_urls �r&�<lambda>z5MultiDomainBasicAuth._get_index_url.<locals>.<lambda>Es-���,��O�O��N�N��#�
�e�C�j�#r%)�reverse�keyr)
r�r�rstrip�urllib�parse�urlsplit�netlocr��sort�
urlunsplit)r.r�
candidates�index�parsed_indexr�r�s      @r&�_get_index_urlz#MultiDomainBasicAuth._get_index_urls����$�/�/��"�3�'�.�.�s�3�c�9���\�\�*�*�3�/�
��
��_�_�E��L�L��%��+�E�!�<�<�0�0�1E�e�1L�M�L��\�)���� � �L�$7�$7�7�����-�-�e�4�I����i�(�%��������	�	
��|�|�&�&�z�!�}�5�5r%F��allow_netrc�
allow_keyring�original_urlr�r�c��t|�\}}}|\}}|�|�tjd|�|S|j|�}	|	r)t|	�}
|
r|
\}	}}tjd|	�|	r&d�!|\}}|�|�tjd|�|S|r%t	|�}
|
rtjd|�|
S|r@|j|	|�xs|j||�}|rtjd|�|S||fS)z2Find and return credentials for the specified URL.zFound credentials in url for %szFound index url %srz%Found credentials in index url for %sz!Found credentials in netrc for %sz#Found credentials in keyring for %s)rrCrDr�rr�)r.r�r�r�rr��url_user_passwordrr�	index_url�
index_info�_�index_url_user_password�
netrc_auth�kr_auths               r&�_get_new_credentialsz)MultiDomainBasicAuth._get_new_credentialsOs:��*D��*
�&��V�&�
/���(���H�$8��L�L�:�F�C�$�$��'�'��,�	��3�I�>�J��8B�5�	�1�5����1�9�=��0��3�?�!8��H�h��#��(<����D�f�M�.�.��'��5�J�����@�&�I�!�!���&�&�y�(�;�9��&�&�v�x�8�
�
����B�F�K�����!�!r%c��t|�\}}}|j|�\}}|�|�+||jvr|j|\}}|�||k(r||}}|�|�|xsd}|xsd}||f|j|<|�|�|�|�
Jd|����|||fS)a_Return the credentials to use for the provided URL.

        If allowed, netrc and keyring may be used to obtain the
        correct credentials.

        Returns (url_without_credentials, username, password). Note
        that even if the original URL contains credentials, this
        function may return a different username and password.
        �z%Could not load credentials from url: )rr�r�)	r.r�rr�r�rr�un�pws	         r&�_get_url_and_credentialsz-MultiDomainBasicAuth._get_url_and_credentials�s���4�L�A���V�Q�"�6�6�|�D���(�
��� 0�f����6N��^�^�F�+�F�B����8�r�>�%'��(����8�#7�
 �~�2�H��~�2�H�'/��%9�D�N�N�6�"��
!�h�&:�� �X�%5�		B�
3�<�.�A�	B�
7�
�H�h�&�&r%�reqc��|j|j�\}}}||_|�|�t||�|�}|jd|j�|S)N�response)r�rr�
register_hook�
handle_401)r.r�rrrs     r&�__call__zMultiDomainBasicAuth.__call__�s_��"&�"?�"?����"H���X�x������H�$8�3�-��(�3�C�8�C�	���*�d�o�o�6��
r%r�c���|jrtd|�d��nd}|sy|jr)|j||�}|r|d�|d�|d|ddfSt	d�}||dfS)	Nz	User for z: )NNFr�Fz
Password: T)r�rr�r�r)r.r�r�authrs     r&�_prompt_for_passwordz)MultiDomainBasicAuth._prompt_for_password�s���9=���9�y����3�4�D���$�����)�)�&�(�;�D���Q��+��Q��0C��A�w��Q���.�.���-����4�'�'r%c��|jr"|jr|jjsyt	dddg�dk(S)NFz#Save credentials to keyring [y/N]: �y�n)r�r�r�r)rr�s r&� _should_save_password_to_keyringz5MultiDomainBasicAuth._should_save_password_to_keyring�s;������#�#��(�(�4�4���8�3��*�E��L�Lr%�resp�kwargsc��|jdk7r|Sd\}}|jr!|j|jdd��\}}|js|s|s|St
jj|j�}d}|s!|s|j|j�\}}}d|_
|�L|�J||f|j|j<|r-|j�rt|j||��|_
|j}|jj!�t#|xsd|xsd�|j$�}|j'd|j(�|jr|j'd|j*�|j,j.|fi|��}	|	j0j3|�|	S)	N�)NNFTr�)rrrr�r�)�status_coder�r�rr�r�r��urlparser�r�r�r�r�r�content�raw�release_connr�requestr��warn_on_401�save_credentials�
connection�send�historyr�)
r.r�r�rr�parsed�saver�r��new_resps
          r&r�zMultiDomainBasicAuth.handle_401�s������s�"��K�'���(����!%�!:�!:����!�"�";�"��H�h��~�~�h�x��K����&�&�t�x�x�0������'+�'@�'@����'O�$�H�h��%)��!���H�$8�-5�x�,@�D�N�N�6�=�=�)���=�=�?�,7��
�
�%�%�-��)�
�L�L��������<�m�H�N��H�N��;�D�L�L�I�����*�d�&6�&6�7�
�$�$����j�$�*?�*?�@�(�4�?�?�'�'��6�v�6��������%��r%c�x�|jdk(r+tjd|jj�yy)z6Response callback to warn about incorrect credentials.r�z)401 Error, Credentials not correct for %sN)r�rCr�r�r)r.r�r�s   r&r�z MultiDomainBasicAuth.warn_on_401s1�����s�"��N�N�;���� � �
�#r%c�t�|jjsJd��|j}d|_|rb|jdkrR	tjd�|jj
|j|j|j�yyy#t$rtjd�YywxYw)z1Response callback to save credentials on success.z'should never reach here without keyringNi�zSaving credentials to keyringzFailed to save credentials)r�r)r�r�rC�infor2rrrr��	exception)r.r�r��credss    r&r�z%MultiDomainBasicAuth.save_credentials's���
�!�!�-�-�	5�4�	5�-��)�)��$(��!��T�%�%��+�
?����;�<��%�%�4�4��I�I�u�~�~�u�~�~��,�5���
?�� � �!=�>�
?�s�AB�B7�6B7)TNro)rr r!r4rr
r"r?�propertyr(r��setterr�rr�r�r�r
r�rr�r�r�rrr�r�r�r$r%r&r�r��s����*.� &�	@��@��T�#�Y�'�@��	@�

�@�"�<�"5�<��<����*��*��*��*��T�T�T��T��
�c�]���3�-��
�(�	�	�4.6�#�.6�(�3�-�.6�h!�#�7"��7"��	7"�
�7"�
�
7"�r.'��.'�	�s�H�S�M�8�C�=�0�	1�.'�`�G����"(��(�	�x��}�h�s�m�T�1�	2�(�M�$�M�=�x�=�3�=�8�=�~���C��D��?�X�?��?��?r%r�)5r3r�rYr�r\r�r��urllib.parser��abcrr�	functoolsr�os.pathr�pathlibrrr	r
rrr
�pip._vendor.requests.authrr�pip._vendor.requests.modelsrr�pip._vendor.requests.utilsr�pip._internal.utils.loggingr�pip._internal.utils.miscrrrrr� pip._internal.vcs.versioncontrolrrrCr~rr(r6r;rJr"r�r�r$r%r&�<module>rs�����	�
���
��#�� ��?�?�=�9�5�1���6�	�8�	�����*��R�#�R�	�-�	�;�/�;�@8�,�8�v�4��:!�3�:!�+>�:!��:!�zV?�8�V?r%

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists