Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_internal/network/__pycache__/auth.cpython-35.pyc



t_-@sdZddlZddlmZmZddlmZddlmZ	ddl
mZmZm
Z
mZmZddlmZerddlmZmZmZmZmZdd	lmZdd
lmZmZeeeefZeje Z!yddl"a"WnXe#k
r da"YnAe$k
r`Z%z!e!j&dee%da"WYddZ%[%XnXdd
Z'GdddeZ(dS)zNetwork Authentication Helpers

Contains interface (MultiDomainBasicAuth) and associated glue code for
providing credentials in the context of network requests.
N)AuthBase
HTTPBasicAuth)get_netrc_auth)parse)ask	ask_inputask_passwordremove_auth_from_urlsplit_auth_netloc_from_url)MYPY_CHECK_RUNNING)DictOptionalTupleListAny)AuthInfo)ResponseRequestz*Keyring is skipped due to an exception: %scCs|strdSyy
tj}Wntk
r6Yn@Xtjd||||}|dk	rr|j|jfSdS|rtjd|tj||}|r||fSWnAtk
r}z!tj	dt
|daWYdd}~XnXdS)z3Return the tuple auth for a given url from keyring.Nz'Getting credentials from keyring for %sz$Getting password from keyring for %sz*Keyring is skipped due to an exception: %s)keyringget_credentialAttributeErrorloggerdebugusernamepasswordget_password	Exceptionwarningstr)urlrrcredrexcr"/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/network/auth.pyget_keyring_auth,s,

r$c@seZdZddddZddZddddZd	d
ZddZd
dZddZ	ddZ
ddZddZdS)MultiDomainBasicAuthTNcCs(||_||_i|_d|_dS)N)	prompting
index_urls	passwords_credentials_to_save)selfr&r'r"r"r#__init__Os			zMultiDomainBasicAuth.__init__cCsY|s|jrdSx=|jD]2}t|jdd}|j|r|SqWdS)aReturn 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/)r'r	rstrip
startswith)r*ruprefixr"r"r#_get_index_url[sz#MultiDomainBasicAuth._get_index_urlcCsUt|\}}}|\}}|dk	rM|dk	rMtjd||S|j|}	|	rt|	}
|
r|
\}	}}tjd|	|	r|ddk	r|\}}|dk	r|dk	rtjd||S|r
t|}
|
r
tjd||
S|rKt|	|p.t||}|rKtjd||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)r
rrr1rr$)r*original_urlallow_netrc
allow_keyringrnetlocurl_user_passwordrr	index_url
index_info_index_url_user_password
netrc_authkr_authr"r"r#_get_new_credentialsrs:z)MultiDomainBasicAuth._get_new_credentialscCst|\}}}|jj|d\}}|dkr]|dkr]|j|\}}|dk	su|dk	r|p~d}|pd}||f|j|<|dk	r|dk	s|dkr|dkstdj||||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.
        Nz'Could not load credentials from url: {})NN)r
r(getr=AssertionErrorformat)r*r2rr5r9rrr"r"r#_get_url_and_credentialssz-MultiDomainBasicAuth._get_url_and_credentialscCsh|j|j\}}}||_|dk	rQ|dk	rQt|||}|jd|j|S)Nresponse)rBrr
register_hook
handle_401)r*reqrrrr"r"r#__call__s	zMultiDomainBasicAuth.__call__cCstdj|}|sdSt||}|ri|ddk	ri|ddk	ri|d|ddfStd}||dfS)Nz
User for {}: Frz
Password: T)NNF)rrAr$r)r*r5rauthrr"r"r#_prompt_for_passwords&z)MultiDomainBasicAuth._prompt_for_passwordcCs#ts
dStdddgdkS)NFz#Save credentials to keyring [y/N]: yn)rr)r*r"r"r# _should_save_password_to_keyringsz5MultiDomainBasicAuth._should_save_password_to_keyringc	Ks;|jdkr|S|js |Stj|j}|j|j\}}}d|_|dk	r|dk	r||f|j|j<|r|j	r|j||f|_|j
|jjt
|pd|pd|j}|jd|j|jr|jd|j|jj||}|jj||S)Nir>rC)status_coder&urllib_parseurlparserrJr5r)r(rMcontentrawrelease_connrrequestrDwarn_on_401save_credentials
connectionsendhistoryappend)	r*respkwargsparsedrrsaverFnew_respr"r"r#rEs(		
$	zMultiDomainBasicAuth.handle_401cKs)|jdkr%tjd|jjdS)z6Response callback to warn about incorrect credentials.iz)401 Error, Credentials not correct for %sN)rNrrrTr)r*r[r\r"r"r#rU sz MultiDomainBasicAuth.warn_on_401cKstdk	stdts"dS|j}d|_|r|jdkrytjdtj|Wntk
rtjdYnXdS)z1Response callback to save credentials on success.Nz'should never reach here without keyringizSaving credentials to keyringzFailed to save credentials)	rr@r)rNrinfoset_passwordr	exception)r*r[r\credsr"r"r#rV(s		

z%MultiDomainBasicAuth.save_credentials)
__name__
__module____qualname__r+r1r=rBrGrJrMrErUrVr"r"r"r#r%Ms2).r%))__doc__loggingZpip._vendor.requests.authrrZpip._vendor.requests.utilsrZpip._vendor.six.moves.urllibrrOpip._internal.utils.miscrrrr	r
pip._internal.utils.typingrtypingrr
rrr pip._internal.vcs.versioncontrolrZpip._vendor.requests.modelsrrrZCredentials	getLoggerrdrrImportErrorrr!rr$r%r"r"r"r#<module>s,((

!
Back to Directory File Manager