HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/pip/_internal/network/__pycache__/auth.cpython-310.pyc
o

��h�P�@sjdZddlmZddlZddlZddlZddlZddlZddlZddl	Z
ddlmZm
Z
ddlmZddlmZddlmZddlmZmZdd	lmZmZdd
lmZmZddlmZddlmZdd
l m!Z!m"Z"m#Z#m$Z$m%Z%ddl&m'Z'ee(�Z)da*Gdd�de�Z+Gdd�de�Z,Gdd�de,�Z-Gdd�de,�Z.Gdd�de,�Z/ed!dd��Z0Gdd �d e�Z1dS)"z�Network Authentication Helpers

Contains interface (MultiDomainBasicAuth) and associated glue code for
providing credentials in the context of network requests.
�)�annotationsN)�ABC�abstractmethod)�cache)�commonprefix)�Path)�Any�
NamedTuple)�AuthBase�
HTTPBasicAuth)�Request�Response)�get_netrc_auth)�	getLogger)�ask�	ask_input�ask_password�remove_auth_from_url�split_auth_netloc_from_url)�AuthInfoFc@s&eZdZUded<ded<ded<dS)�Credentials�str�url�username�passwordN)�__name__�
__module__�__qualname__�__annotations__�rr�E/usr/local/lib/python3.10/dist-packages/pip/_internal/network/auth.pyr)s
rc@s6eZdZUdZded<edd
d��Zeddd��ZdS)�KeyRingBaseProviderzKeyring base provider interface�bool�has_keyringrrr�
str | None�return�AuthInfo | NonecC�dS�Nr��selfrrrrr �
get_auth_info4�z!KeyRingBaseProvider.get_auth_infor�NonecCr'r(r�r*rrrrrr �save_auth_info7r,z"KeyRingBaseProvider.save_auth_infoN�rrrr$r%r&�rrrrrrr%r-)rrr�__doc__rrr+r/rrrr r!/s
r!c@s(eZdZdZdZdd	d
�Zdd
d�ZdS)�KeyRingNullProviderzKeyring null providerFrrrr$r%r&cCr'r(rr)rrr r+@r,z!KeyRingNullProvider.get_auth_inforr-cCr'r(rr.rrr r/Cr,z"KeyRingNullProvider.save_auth_infoNr0r1)rrrr2r#r+r/rrrr r3;s

r3c@s2eZdZdZdZddd�Zddd
�Zddd�ZdS)�KeyRingPythonProviderz7Keyring interface which uses locally imported `keyring`Tr%r-cCsddl}||_dS)Nr��keyring)r*r6rrr �__init__Ls
zKeyRingPythonProvider.__init__rrrr$r&cCspt|jd�rt�d|�|j�||�}|dur|j|jfSdS|dur6t�d|�|j�||�}|r6||fSdS)N�get_credentialz'Getting credentials from keyring for %sz$Getting password from keyring for %s)�hasattrr6�logger�debugr8rr�get_password)r*rr�credrrrr r+Qsz#KeyRingPythonProvider.get_auth_inforcCs|j�|||�dSr()r6�set_passwordr.rrr r/csz$KeyRingPythonProvider.save_auth_infoN)r%r-r0r1)rrrr2r#r7r+r/rrrr r4Gs

r4c@sFeZdZdZdZddd�Zdd
d�Zddd�Zddd�Zddd�Z	dS)�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�cmdrr%r-cC�
||_dSr(r5)r*r@rrr r7rs
zKeyRingCliProvider.__init__rrr$r&cCs(|dur|�||�}|dur||fSdSr()�
_get_passwordr.rrr r+us
z KeyRingCliProvider.get_auth_inforcCs|�|||�Sr()�
_set_passwordr.rrr r/~sz!KeyRingCliProvider.save_auth_info�service_namecCsb|jdurdS|jd||g}tj��}d|d<tj|tjtj|d�}|jr'dS|j	�
d��tj�S)z;Mirror the implementation of keyring.get_password using cliN�get�utf-8�PYTHONIOENCODING)�stdin�stdout�env)
r6�os�environ�copy�
subprocess�run�DEVNULL�PIPE�
returncoderI�decode�strip�linesep)r*rDrr@rJ�resrrr rB�s

�z KeyRingCliProvider._get_passwordcCsN|jdurdStj��}d|d<tj|jd||g|�tj����|dd�dS)z;Mirror the implementation of keyring.set_password using cliNrFrG�setT)�inputrJ�check)r6rKrLrMrNrOrU�encode)r*rDrrrJrrr rC�s

�z KeyRingCliProvider._set_passwordN)r@rr%r-r0r1)rDrrrr%r$)rDrrrrrr%r-)
rrrr2r#r7r+r/rBrCrrrr r?gs


	
r?�providerrr%c

Csdt�d|�tr
d}|dvrJzt�}t�d�|WSty"Yn(tyI}zd}|dkr3|d}tj||t�tj	�d�WYd}~nd}~ww|d	vr�t
�d
�}|r�|�t
�d��r�tjddd��}tt
�d��}g}|��tj�D]}t|�}	z|	�|�s�|�|�Wquty�Yquwtj�|�}t
jd
|d�}|r�t�d|�t|�St�d�t�S)NzKeyring provider requested: %s�disabled)�import�autozKeyring provider set: importz1Installed copy of keyring fails with exception %sr^z3, trying to find a keyring executable as a fallback��exc_info)rNr^r6�scriptsr%rc	SsJtj�dd�}|dur#zt�d�}W|Sttfy"tj}Y|Sw|S)N�PATH�CS_PATH)rKrLrE�confstr�AttributeError�
ValueError�defpath��pathrrr �"PATH_as_shutil_which_determines_it�s��z@get_keyring_provider.<locals>.PATH_as_shutil_which_determines_itrhz3Keyring provider set: subprocess with executable %szKeyring provider set: disabled)r%r)r:�verbose�KEYRING_DISABLEDr4�ImportError�	Exception�warning�isEnabledFor�logging�DEBUG�shutil�which�
startswith�	sysconfig�get_path�typing�
no_type_checkr�splitrK�pathsep�samefile�append�FileNotFoundError�joinr?r3)
r[�impl�exc�msg�clirjra�pathsri�prrr �get_keyring_provider�sP
$��



��
r�c@s�eZdZ			d<d=dd
�Zed>dd��Zejd?dd��Zed@dd��ZdAdd�ZdBdd�Z	ddd�dCd#d$�Z
dDd&d'�ZdEd*d+�ZdFd.d/�Z
d@d0d1�ZdGd6d7�ZdHd8d9�ZdHd:d;�ZdS)I�MultiDomainBasicAuthTNr^�	promptingr"�
index_urls�list[str] | None�keyring_providerrr%r-cCs"||_||_||_i|_d|_dSr()r�r�r��	passwords�_credentials_to_save)r*r�r�r�rrr r7�s

zMultiDomainBasicAuth.__init__r!cCs
t|j�Sr()r��_keyring_provider�r*rrr r��s
z%MultiDomainBasicAuth.keyring_providerr[cCrAr()r�)r*r[rrr r��s
cCs|jp|jdvS)N)r^r\)r�r�r�rrr �use_keyring�sz MultiDomainBasicAuth.use_keyringrr$rr&c
Csj|sdSz|j�||�WSty4}ztjddd�t�dt|��dat�	�WYd}~dSd}~ww)z3Return the tuple auth for a given url from keyring.Nz&Keyring is skipped due to an exceptionTr_z*Keyring is skipped due to an exception: %s)
r�r+rnr:r;rorrlr��cache_clear)r*rrr�rrr �_get_keyring_auths���z&MultiDomainBasicAuth._get_keyring_authcs�|r|jsdSt|��d�d}tj�|��g}|jD]+}|�d�d}tj�t|��}�|kr4|S�j|jkr;qtj�|�}|�|�q|sKdS|jd�fdd�d�tj�	|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�/Tcst�j|jg��d�S)Nr�)rri�rfind)�	candidate��
parsed_urlrr �<lambda>Es��z5MultiDomainBasicAuth._get_index_url.<locals>.<lambda>)�reverse�keyr)
r�r�rstrip�urllib�parse�urlsplit�netlocr}�sort�
urlunsplit)r*r�
candidates�index�parsed_indexr�rr�r �_get_index_urls*



�
z#MultiDomainBasicAuth._get_index_urlF��allow_netrc�
allow_keyring�original_urlr�r�rcCs�t|�\}}}|\}}|dur|durt�d|�|S|�|�}	|	r3t|	�}
|
r3|
\}	}}t�d|	�|	rO|ddurO|\}}|durO|durOt�d|�|S|r_t|�}
|
r_t�d|�|
S|rw|�|	|�pl|�||�}|rwt�d|�|S||fS)z2Find and return credentials for the specified URL.NzFound 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)rr:r;r�rr�)r*r�r�r�rr��url_user_passwordrr�	index_url�
index_info�_�index_url_user_password�
netrc_auth�kr_authrrr �_get_new_credentialsOs>	
�


�z)MultiDomainBasicAuth._get_new_credentials�"tuple[str, str | None, str | None]c	Cs�t|�\}}}|�|�\}}|dus|dur/||jvr/|j|\}}|dus*||kr/||}}|dus7|durF|p:d}|p>d}||f|j|<|durN|dus]|durV|dus]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.
        N�z%Could not load credentials from url: )rr�r�)	r*r�rr�r�rr�un�pwrrr �_get_url_and_credentials�s
�
z-MultiDomainBasicAuth._get_url_and_credentials�reqrcCsH|�|j�\}}}||_|dur|durt||�|�}|�d|j�|S)N�response)r�rr�
register_hook�
handle_401)r*r�rrrrrr �__call__�szMultiDomainBasicAuth.__call__r��#tuple[str | None, str | None, bool]cCst|jrtd|�d��nd}|sdS|jr1|�||�}|r1|ddur1|ddur1|d|ddfStd�}||dfS)	Nz	User for z: )NNFr�Fz
Password: T)r�rr�r�r)r*r�r�authrrrr �_prompt_for_password�s
z)MultiDomainBasicAuth._prompt_for_passwordcCs*|jr
|jr
|jjsdStdddg�dkS)NFz#Save credentials to keyring [y/N]: �y�n)r�r�r�r#rr�rrr � _should_save_password_to_keyring�s���z5MultiDomainBasicAuth._should_save_password_to_keyring�respr
�kwargsrc
Ks"|jdkr|Sd\}}|jr|j|jddd�\}}|js"|s"|s"|Stj�|j�}d}|s8|s8|�|j	�\}}}d|_
|durZ|durZ||f|j|j	<|rZ|��rZt
|j	||d�|_
|j}|j��t|pfd|pid�|j�}|�d|j�|j
r|�d|j�|jj|fi|��}	|	j�|�|	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_resprrr r��sB

��

zMultiDomainBasicAuth.handle_401cKs"|jdkrt�d|jj�dSdS)z6Response callback to warn about incorrect credentials.r�z)401 Error, Credentials not correct for %sN)r�r:ror�r)r*r�r�rrr r�s
��z MultiDomainBasicAuth.warn_on_401cKsx|jjsJd��|j}d|_|r8|jdkr:zt�d�|j�|j|j|j	�WdSt
y7t�d�YdSwdSdS)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�r:�infor/rrrrn�	exception)r*r�r��credsrrr r�%s ��

���z%MultiDomainBasicAuth.save_credentials)TNr^)r�r"r�r�r�rr%r-)r%r!)r[rr%r-)r%r")rr$rr$r%r&)rrr%r$)r�rr�r"r�r"r%r)r�rr%r�)r�rr%r)r�rr%r�)r�r
r�rr%r
)r�r
r�rr%r-)rrrr7�propertyr��setterr�r�r�r�r�r�r�r�r�r�r�rrrr r��s.�

4�
9
0


	
?r�)r[rr%r!)2r2�
__future__rrqrKrsrNrvrx�urllib.parser��abcrr�	functoolsr�os.pathr�pathlibrrr	�pip._vendor.requests.authr
r�pip._vendor.requests.modelsrr
�pip._vendor.requests.utilsr�pip._internal.utils.loggingr�pip._internal.utils.miscrrrrr� pip._internal.vcs.versioncontrolrrr:rlrr!r3r4r?r�r�rrrr �<module>s< ;=