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.7/site-packages/pip/_internal/network/__pycache__/auth.cpython-37.pyc
B

L��g=P�@szdZddlZddlZddlZddlZddlZddlZddlZddl	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,Gdd�de�Z-Gdd�de
�Z.Gdd�de.�Z/Gdd�de.�Z0Gdd�de.�Z1e
dd�e2e.d�dd��Z3Gdd�de�Z4dS)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@s&eZdZUeed<eed<eed<dS)�Credentials�url�username�passwordN)�__name__�
__module__�__qualname__�str�__annotations__�r"r"�>/tmp/pip-unpacked-wheel-hv55ucu3/pip/_internal/network/auth.pyr&s
rc@sPeZdZUdZeed<eeeeee	d�dd��Z
eeeedd�dd	��ZdS)
�KeyRingBaseProviderzKeyring base provider interface�has_keyring)rr�returncCsdS)Nr")�selfrrr"r"r#�
get_auth_info1sz!KeyRingBaseProvider.get_auth_infoN)rrrr&cCsdS)Nr")r'rrrr"r"r#�save_auth_info5sz"KeyRingBaseProvider.save_auth_info)rrr�__doc__�boolr!rr rrr(r)r"r"r"r#r$,s
r$c@sBeZdZdZdZeeeeed�dd�Zeeedd�dd	�Z	dS)
�KeyRingNullProviderzKeyring null providerF)rrr&cCsdS)Nr")r'rrr"r"r#r(?sz!KeyRingNullProvider.get_auth_infoN)rrrr&cCsdS)Nr")r'rrrr"r"r#r)Bsz"KeyRingNullProvider.save_auth_info)
rrrr*r%r rrr(r)r"r"r"r#r,:sr,c@sPeZdZdZdZdd�dd�Zeeeeed�dd	�Z	eeedd
�dd�Z
dS)
�KeyRingPythonProviderz7Keyring interface which uses locally imported `keyring`TN)r&cCsddl}||_dS)Nr)�keyring)r'r.r"r"r#�__init__KszKeyRingPythonProvider.__init__)rrr&cCspt|jd�r>t�d|�|j�||�}|dk	r:|j|jfSdS|dk	rlt�d|�|j�||�}|rl||fSdS)N�get_credentialz'Getting credentials from keyring for %sz$Getting password from keyring for %s)�hasattrr.�logger�debugr0rr�get_password)r'rr�credrr"r"r#r(Psz#KeyRingPythonProvider.get_auth_info)rrrr&cCs|j�|||�dS)N)r.�set_password)r'rrrr"r"r#r)bsz$KeyRingPythonProvider.save_auth_info)rrrr*r%r/r rrr(r)r"r"r"r#r-Fs
r-c@s|eZdZdZdZedd�dd�Zeeeeed�dd	�Z	eeedd
�dd�Z
eeeed
�dd�Zeeedd�dd�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.
    TN)�cmdr&cCs
||_dS)N)r.)r'r8r"r"r#r/qszKeyRingCliProvider.__init__)rrr&cCs(|dk	r$|�||�}|dk	r$||fSdS)N)�
_get_password)r'rrrr"r"r#r(ts
z KeyRingCliProvider.get_auth_info)rrrr&cCs|�|||�S)N)�
_set_password)r'rrrr"r"r#r)}sz!KeyRingCliProvider.save_auth_info)�service_namerr&cCsb|jdkrdS|jd||g}tj��}d|d<tj|tjtj|d�}|jrNdS|j	�
d��tj�S)z;Mirror the implementation of keyring.get_password using cliN�getzutf-8�PYTHONIOENCODING)�stdin�stdout�env)
r.�os�environ�copy�
subprocess�run�DEVNULL�PIPE�
returncoder?�decode�strip�linesep)r'r;rr8r@�resr"r"r#r9�s

z KeyRingCliProvider._get_password)r;rrr&cCsP|jdkrdStj��}d|d<tj|jd||g|�tj���d�|dd�dS)z;Mirror the implementation of keyring.set_password using cliNzutf-8r=�setT)�inputr@�check)r.rArBrCrDrErK�encode)r'r;rrr@r"r"r#r:�s

z KeyRingCliProvider._set_password)
rrrr*r%r r/rrr(r)r9r:r"r"r"r#r7fs	r7)�maxsize)�providerr&c

Cszt�d|�trd}|dkr�yt�}t�d�|Stk
rDYnNtk
r�}z0d}|dkrh|d}tj||t�tj	�d�Wdd}~XYnX|d	k�rjt
�d
�}|�rP|�t
�d���rPtjtd�d
d��}tt
�d��}g}xP|��tj�D]>}t|�}	y|	�|��s|�|�Wq�tk
�r0Yq�Xq�Wtj�|�}t
jd
|d�}|�rjt�d|�t|�St�d�t�S)NzKeyring provider requested: %s�disabled)�import�autozKeyring provider set: importz1Installed copy of keyring fails with exception %srUz3, trying to find a keyring executable as a fallback)�exc_info)rDrUr.�scripts)r&c	SsHtj�dd�}|dkrDyt�d�}Wnttfk
rBtj}YnX|S)N�PATH�CS_PATH)rArBr<�confstr�AttributeError�
ValueError�defpath)�pathr"r"r#�"PATH_as_shutil_which_determines_it�sz@get_keyring_provider.<locals>.PATH_as_shutil_which_determines_it)r^z3Keyring provider set: subprocess with executable %szKeyring provider set: disabled)r2�verbose�KEYRING_DISABLEDr-�ImportError�	Exception�warning�isEnabledFor�logging�DEBUG�shutil�which�
startswith�	sysconfig�get_path�typing�
no_type_checkr r�splitrA�pathsep�samefile�append�FileNotFoundError�joinr7r,)
rR�impl�exc�msg�clir_rW�pathsr^�pr"r"r#�get_keyring_provider�sH
*




r{c@sJeZdZd+eeeeedd�dd�Zee	d�dd	��Z
e
jedd
�dd	��Z
eed�dd
��Zeeeeee
d�dd�Zeeed�dd�Zddd�eeee
d�dd�Zeeeeeeefd�dd�Zeed�dd�Zeeeeeeefd�d d!�Zed�d"d#�Zeeed$�d%d&�Zeedd$�d'd(�Zeedd$�d)d*�ZdS),�MultiDomainBasicAuthTNrU)�	prompting�
index_urls�keyring_providerr&cCs"||_||_||_i|_d|_dS)N)r}r~r�	passwords�_credentials_to_save)r'r}r~rr"r"r#r/�s
zMultiDomainBasicAuth.__init__)r&cCs
t|j�S)N)r{�_keyring_provider)r'r"r"r#r�sz%MultiDomainBasicAuth.keyring_provider)rRr&cCs
||_dS)N)r�)r'rRr"r"r#r�scCs|jp|jdkS)N)rUrS)r}r�)r'r"r"r#�use_keyring�sz MultiDomainBasicAuth.use_keyring)rrr&c
CsZ|sdSy|j�||�Stk
rT}z t�dt|��dat��dSd}~XYnXdS)z3Return the tuple auth for a given url from keyring.Nz*Keyring is skipped due to an exception: %sT)	rr(rcr2rdr rar{�cache_clear)r'rrrvr"r"r#�_get_keyring_auths
z&MultiDomainBasicAuth._get_keyring_auth)rr&cs�|r
|jsdSt|��d�d}tj�|��g}x\|jD]R}|�d�d}tj�t|��}�|krf|S�j|jkrtq8tj�|�}|�|�q8W|s�dS|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�)rr^�rfind)�	candidate)�
parsed_urlr"r#�<lambda>@s
z5MultiDomainBasicAuth._get_index_url.<locals>.<lambda>)�reverse�keyr)
r~r�rstrip�urllib�parse�urlsplit�netlocrr�sort�
urlunsplit)r'r�
candidates�indexZparsed_indexr�r")r�r#�_get_index_urls(
z#MultiDomainBasicAuth._get_index_urlF)�allow_netrc�
allow_keyring)�original_urlr�r�r&cCs�t|�\}}}|\}}|dk	r6|dk	r6t�d|�|S|�|�}	|	rft|	�}
|
rf|
\}	}}t�d|	�|	r�|ddk	r�|\}}|dk	r�|dk	r�t�d|�|S|r�t|�}
|
r�t�d|�|
S|r�|�|	|�p�|�||�}|r�t�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)rr2r3r�rr�)r'r�r�r�rr��url_user_passwordrr�	index_url�
index_info�_�index_url_user_password�
netrc_auth�kr_authr"r"r#�_get_new_credentialsJs:	

z)MultiDomainBasicAuth._get_new_credentials)r�r&c	Cs�t|�\}}}|�|�\}}|dks,|dkr^||jkr^|j|\}}|dksT||kr^||}}|dk	sn|dk	r�|ptd}|p|d}||f|j|<|dk	r�|dk	s�|dkr�|dks�td|����|||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��AssertionError)	r'r�rr�r�rrZun�pwr"r"r#�_get_url_and_credentials�s
z-MultiDomainBasicAuth._get_url_and_credentials)�reqr&cCsH|�|j�\}}}||_|dk	r6|dk	r6t||�|�}|�d|j�|S)N�response)r�rr�
register_hook�
handle_401)r'r�rrrr"r"r#�__call__�szMultiDomainBasicAuth.__call__)r�r&cCst|jrtd|�d��nd}|s"dS|jrb|�||�}|rb|ddk	rb|ddk	rb|d|ddfStd�}||dfS)	Nz	User for z: )NNFr�Fz
Password: T)r}rr�r�r)r'r�r�authrr"r"r#�_prompt_for_password�sz)MultiDomainBasicAuth._prompt_for_passwordcCs*|jr|jr|jjsdStdddg�dkS)NFz#Save credentials to keyring [y/N]: �y�n)r}r�rr%r)r'r"r"r#� _should_save_password_to_keyring�s
z5MultiDomainBasicAuth._should_save_password_to_keyring)�resp�kwargsr&c
Ks|jdkr|Sd\}}|jr2|j|jddd�\}}|jsD|sD|sD|Stj�|j�}d}|sp|sp|�|j	�\}}}d|_
|dk	r�|dk	r�||f|j|j	<|r�|��r�t
|j	||d�|_
|j}|j��t|p�d|p�d�|j�}|�d|j�|j
r�|�d|j�|jj|f|�}	|	j�|�|	S)	Ni�)NNFT)r�r�)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�historyrr)
r'r�r�rr�parsed�saver�r��new_respr"r"r#r��s>


zMultiDomainBasicAuth.handle_401cKs|jdkrt�d|jj�dS)z6Response callback to warn about incorrect credentials.i�z)401 Error, Credentials not correct for %sN)r�r2rdr�r)r'r�r�r"r"r#r�s
z MultiDomainBasicAuth.warn_on_401cKsr|jjstd��|j}d|_|rn|jdkrny$t�d�|j�|j|j	|j
�Wntk
rlt�d�YnXdS)z1Response callback to save credentials on success.z'should never reach here without keyringNi�zSaving credentials to keyringzFailed to save credentials)
rr%r�r�r�r2�infor)rrrrc�	exception)r'r�r��credsr"r"r#r�"s

z%MultiDomainBasicAuth.save_credentials)TNrU)rrrr+rr	r r/�propertyr$r�setterr�rr�r�r�rr�rr�r�r�rrr�r�r�r"r"r"r#r|�s444 . 	?r|)5r*rfrArhrDrkrm�urllib.parser��abcrr�	functoolsr�os.pathr�pathlibrrrr	r
rrZpip._vendor.requests.authr
rZpip._vendor.requests.modelsrrZpip._vendor.requests.utilsr�pip._internal.utils.loggingr�pip._internal.utils.miscrrrrr� pip._internal.vcs.versioncontrolrrr2rarr$r,r-r7r r{r|r"r"r"r#�<module>s8  ;=