HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/site-packages/pip/_internal/network/__pycache__/auth.cpython-310.pyc
o

��i{@�@sTdZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZm
Z
mZmZddlmZmZddlmZmZddlmZddlmZdd	lmZmZmZmZmZdd
l m!Z!ee"�Z#da$Gdd
�d
e
�Z%Gdd�de�Z&Gdd�de&�Z'Gdd�de&�Z(Gdd�de&�Z)de&fdd�Z*dee+dee+dee!fdd�Z,Gdd�de�Z-dS)z�Network Authentication Helpers

Contains interface (MultiDomainBasicAuth) and associated glue code for
providing credentials in the context of network requests.
�N)�ABC�abstractmethod)�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@s&eZdZUeed<eed<eed<dS)�Credentials�url�username�passwordN)�__name__�
__module__�__qualname__�str�__annotations__�rr�E/usr/local/lib/python3.10/site-packages/pip/_internal/network/auth.pyr!s
rc	@sPeZdZdZededeedeefdd��Zededededdfd	d
��Z	dS)�KeyRingBaseProviderzKeyring base provider interfacerr�returncC�dS�Nr��selfrrrrr �
get_auth_info*�z!KeyRingBaseProvider.get_auth_inforNcCr#r$r�r&rrrrrr �save_auth_info.r(z"KeyRingBaseProvider.save_auth_info)
rrr�__doc__rrrrr'r*rrrr r!'s  r!c@sHeZdZdZdedeedeefdd�Zdedededdfd	d
�ZdS)�KeyRingNullProviderzKeyring null providerrrr"cCr#r$rr%rrr r'6�z!KeyRingNullProvider.get_auth_inforNcCr#r$rr)rrr r*9r-z"KeyRingNullProvider.save_auth_info)	rrrr+rrrr'r*rrrr r,3sr,c@sReZdZdZd
dd�Zdedeedeefdd	�Zdeded
eddfdd�Z	dS)�KeyRingPythonProviderz7Keyring interface which uses locally imported `keyring`r"NcCsddl}||_dS)Nr��keyring)r&r0rrr �__init__@s
zKeyRingPythonProvider.__init__rrcCspt|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)�hasattrr0�logger�debugr2rr�get_password)r&rr�credrrrr r'Esz#KeyRingPythonProvider.get_auth_inforcCs|j�|||�dSr$)r0�set_passwordr)rrr r*Wsz$KeyRingPythonProvider.save_auth_info)r"N)
rrrr+r1rrrr'r*rrrr r.=s

r.c@s�eZdZdZdeddfdd�Zdedeedeefd	d
�Zdedededdfdd
�Z	dededeefdd�Z
dedededdfdd�ZdS)�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.
    �cmdr"NcCs
||_dSr$r/)r&r:rrr r1ds
zKeyRingCliProvider.__init__rrcCs(|dur|�||�}|dur||fSdSr$)�
_get_passwordr)rrr r'gs
z KeyRingCliProvider.get_auth_inforcCs|�|||�Sr$)�
_set_passwordr)rrr r*psz!KeyRingCliProvider.save_auth_info�service_namecCs`|jdurdS|jd||g}tj��}d|d<tj|tjd|d�}|jr&dS|j�	d��
tj�S)z;Mirror the implementation of keyring.get_password using cliN�get�utf-8�PYTHONIOENCODINGT)�stdin�capture_output�env)r0�os�environ�copy�
subprocess�run�DEVNULL�
returncode�stdout�decode�strip�linesep)r&r=rr:rC�resrrr r;ss

�z KeyRingCliProvider._get_passwordcCsZ|jdurdS|jd||g}|tj�d�}tj��}d|d<tj|||d�}|��dS)z;Mirror the implementation of keyring.set_password using cliN�setr?r@)�inputrC)	r0rDrN�encoderErFrGrH�check_returncode)r&r=rrr:�input_rCrOrrr r<�s

z KeyRingCliProvider._set_password)rrrr+rr1rrr'r*r;r<rrrr r9[s	r9r"c
Csnts4zt�WStyYnty(}zt�dt|��WYd}~nd}~wwt�d�}|r4t	|�St
�S)NzdInstalled copy of keyring fails with exception %s, trying to find a keyring executable as a fallbackr0)�KEYRING_DISABLEDr.�ImportError�	Exceptionr4�warningr�shutil�whichr9r,)�exc�clirrr �get_keyring_provider�s ���

r]rrc
CsX|sdSt�}z|�||�WSty+}zt�dt|��daWYd}~dSd}~ww)z3Return the tuple auth for a given url from keyring.Nz*Keyring is skipped due to an exception: %sT)r]r'rWr4rXrrU)rrr0r[rrr �get_keyring_auth�s���r^c	@seZdZ	d#dedeeeddfdd�Zdedeefd	d
�Z		d$ded
edede	fdd�Z
dedeeeeeeffdd�Zde
de
fdd�Zdedeeeeeeffdd�Zdefdd�Zdededefdd�Zdededdfdd �Zdededdfd!d"�ZdS)%�MultiDomainBasicAuthTN�	prompting�
index_urlsr"cCs||_||_i|_d|_dSr$)r`ra�	passwords�_credentials_to_save)r&r`rarrr r1�s
zMultiDomainBasicAuth.__init__rcCsB|r|jsdS|jD]}t|��d�d}|�|�r|Sq
dS)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�/)rar�rstrip�
startswith)r&r�u�prefixrrr �_get_index_url�s



�z#MultiDomainBasicAuth._get_index_urlF�original_url�allow_netrc�
allow_keyringcCs�t|�\}}}|\}}|dur|durt�d|�|S|�|�}	|	r3t|	�}
|
r3|
\}	}}t�d|	�|	rO|ddurO|\}}|durO|durOt�d|�|S|r_t|�}
|
r_t�d|�|
S|rut|	|�pjt||�}|rut�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)rr4r5rirr^)r&rjrkrlr�netloc�url_user_passwordrr�	index_url�
index_info�_�index_url_user_password�
netrc_auth�kr_authrrr �_get_new_credentials�s>
�


�z)MultiDomainBasicAuth._get_new_credentialsc	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: )rrurb)	r&rjrrmrqrr�un�pwrrr �_get_url_and_credentialss
�
z-MultiDomainBasicAuth._get_url_and_credentials�reqcCsH|�|j�\}}}||_|dur|durt||�|�}|�d|j�|S)N�response)ryrr�
register_hook�
handle_401)r&rzrrrrrr �__call__KszMultiDomainBasicAuth.__call__rmcCsbtd|�d��}|sdSt||�}|r(|ddur(|ddur(|d|ddfStd�}||dfS)	Nz	User for z: )NNFr�Fz
Password: T)rr^r)r&rmr�authrrrr �_prompt_for_password\s

z)MultiDomainBasicAuth._prompt_for_passwordcCs t�durdStdddg�dkS)NFz#Save credentials to keyring [y/N]: �y�n)r]r)r&rrr � _should_save_password_to_keyringis
z5MultiDomainBasicAuth._should_save_password_to_keyring�resp�kwargsc	Ks|jdkr|S|js|Stj�|j�}|j|jddd�\}}d}|s-|s-|�|j�\}}}d|_	|durO|durO||f|j
|j<|rO|��rOt|j||d�|_	|j
|j��t|p[d|p^d�|j�}|�d|j�|j	rt|�d|j�|jj|fi|��}|j�|�|S)N�FT)rkrl)rrrrvr{)�status_coder`�urllib�parse�urlparserrur�rmrcrbr�r�content�raw�release_connr�requestr|�warn_on_401�save_credentials�
connection�send�history�append)	r&r�r��parsedrr�saverz�new_resprrr r}ns>

��
zMultiDomainBasicAuth.handle_401cKs"|jdkrt�d|jj�dSdS)z6Response callback to warn about incorrect credentials.r�z)401 Error, Credentials not correct for %sN)r�r4rXr�r)r&r�r�rrr r��s
��z MultiDomainBasicAuth.warn_on_401cKs~t�}t|t�rJd��|j}d|_|r;|jdkr=zt�d�|�|j|j	|j
�WdSty:t�d�YdSwdSdS)z1Response callback to save credentials on success.z'should never reach here without keyringNi�zSaving credentials to keyringzFailed to save credentials)
r]�
isinstancer,rcr�r4�infor*rrrrW�	exception)r&r�r�r0�credsrrr r��s ��
��z%MultiDomainBasicAuth.save_credentials)TN)TF)rrr�boolrrrr1rirrur	ryrr~r�r�r
rr}r�r�rrrr r_�sH��
�
�
����
�8�
�0�
�
:r_).r+rDrYrG�urllib.parser��abcrr�typingrrrrrr	Zpip._vendor.requests.authr
rZpip._vendor.requests.modelsrr
Zpip._vendor.requests.utilsr�pip._internal.utils.loggingr�pip._internal.utils.miscrrrrr� pip._internal.vcs.versioncontrolrrr4rUrr!r,r.r9r]rr^r_rrrr �<module>s. 
8"