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



t_'@sdZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZddlmZddlmZd	Zd
ZddZGd
ddeZGdddeZGdddeZGdddeZdS)z]
requests.auth
~~~~~~~~~~~~~

This module contains the authentication handlers for Requests.
N)	b64encode)urlparsestr
basestring)extract_cookies_to_jar)to_native_string)parse_dict_headerz!application/x-www-form-urlencodedzmultipart/form-datacCst|ts7tjdj|dtt|}t|tsttjdjt|dtt|}t|tr|jd}t|tr|jd}dt	t
dj||fj}|S)zReturns a Basic Auth string.zNon-string usernames will no longer be supported in Requests 3.0.0. Please convert the object you've passed in ({!r}) to a string or bytes object in the near future to avoid problems.categoryzNon-string passwords will no longer be supported in Requests 3.0.0. Please convert the object you've passed in ({!r}) to a string or bytes object in the near future to avoid problems.latin1zBasic :)
isinstancerwarningswarnformatDeprecationWarningrtypeencoderrjoinstrip)usernamepasswordauthstrr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/auth.py_basic_auth_strs&
	%rc@s"eZdZdZddZdS)AuthBasez4Base class that all auth implementations derive fromcCstddS)NzAuth hooks must be callable.)NotImplementedError)selfrrrr__call__KszAuthBase.__call__N)__name__
__module____qualname____doc__r rrrrrHsrc@sFeZdZdZddZddZddZdd	Zd
S)
HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS)N)rr)rrrrrr__init__Rs	zHTTPBasicAuth.__init__cCs:t|jt|ddk|jt|ddkgS)Nrr)allrgetattrr)rotherrrr__eq__VszHTTPBasicAuth.__eq__cCs||kS)Nr)rr)rrr__ne__\szHTTPBasicAuth.__ne__cCs t|j|j|jd<|S)N
Authorization)rrrheaders)rrrrrr _szHTTPBasicAuth.__call__N)r!r"r#r$r&r*r+r rrrrr%Os
r%c@s"eZdZdZddZdS)
HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cCs t|j|j|jd<|S)NzProxy-Authorization)rrrr-)rrrrrr gszHTTPProxyAuth.__call__N)r!r"r#r$r rrrrr.dsr.c@sveZdZdZddZddZddZdd	Zd
dZdd
Z	ddZ
ddZdS)HTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.cCs%||_||_tj|_dS)N)rr	threadinglocal
_thread_local)rrrrrrr&os		zHTTPDigestAuth.__init__cCs^t|jdsZd|j_d|j_d|j_i|j_d|j_d|j_dS)NinitTr)hasattrr2r3
last_noncenonce_countchalpos
num_401_calls)rrrrinit_per_thread_stateusz$HTTPDigestAuth.init_per_thread_statecs|jjd}|jjd}|jjjd}|jjjd}|jjjd}d|dkrzd}n|j}|dks|dkrd	d
}	|	n`|dkrdd
}
|
n?|dkrdd}|n|dkrdd}|fdd}
dkr5dSd}t|}|jpSd}|jrp|d|j7}d|j||jf}d||f}|}|}||jj	kr|jj
d7_
nd|j_
d|jj
}t|jj
jd}||jd7}|t
jjd7}|tjd7}tj|jdd}|dkrd|||f}|s|
|d||f}nP|dksd|jd krd!|||d|f}|
||}ndS||j_	d"|j||||f}|r@|d#|7}|rT|d$|7}|rh|d%|7}|r|d&||f7}d'|S)(z
        :rtype: str
        realmnonceqop	algorithmopaqueNMD5zMD5-SESScSs1t|tr|jd}tj|jS)Nzutf-8)r
rrhashlibmd5	hexdigest)xrrrmd5_utf8sz4HTTPDigestAuth.build_digest_header.<locals>.md5_utf8SHAcSs1t|tr|jd}tj|jS)Nzutf-8)r
rrrBsha1rD)rErrrsha_utf8sz4HTTPDigestAuth.build_digest_header.<locals>.sha_utf8zSHA-256cSs1t|tr|jd}tj|jS)Nzutf-8)r
rrrBsha256rD)rErrrsha256_utf8sz7HTTPDigestAuth.build_digest_header.<locals>.sha256_utf8zSHA-512cSs1t|tr|jd}tj|jS)Nzutf-8)r
rrrBsha512rD)rErrrsha512_utf8sz7HTTPDigestAuth.build_digest_header.<locals>.sha512_utf8csd||fS)Nz%s:%sr)sd)	hash_utf8rr<lambda>sz4HTTPDigestAuth.build_digest_header.<locals>.<lambda>/?z%s:%s:%sz%s:%srz%08xzutf-8auth,z%s:%s:%s:%s:%sz>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"z
, opaque="%s"z, algorithm="%s"z
, digest="%s"z , qop="auth", nc=%s, cnonce="%s"z	Digest %s)r2r8getupperrpathqueryrrr6r7rrtimectimeosurandomrBrHrDsplit)rmethodurlr<r=r>r?r@
_algorithmrFrIrKrMKDentdigp_parsedrZA1A2HA1HA2ncvaluerNcnoncerespdignoncebitbaser)rPrbuild_digest_headers~					!z"HTTPDigestAuth.build_digest_headercKs|jrd|j_dS)z)Reset num_401_calls counter on redirects.rN)is_redirectr2r:)rrkwargsrrrhandle_redirects	zHTTPDigestAuth.handle_redirectcKsd|jkodkns/d|j_|S|jjdk	rZ|jjj|jj|jjdd}d|j	kr{|jjdkr{|jjd7_t
jd	d
t
j}t
|jd|dd|j_|j|j|jj}t|j|j|j|j|j|j|j|j|jd<|jj||}|jj|||_|Sd|j_|S)
zo
        Takes the given response and tries digest-auth, if needed.

        :rtype: requests.Response
        iirNzwww-authenticater4digestzdigest flagscountr,)status_coder2r:r9requestbodyseekr-rXlowerrecompile
IGNORECASEr	subr8contentclosecopyr_cookiesrawprepare_cookiesrprarb
connectionsendhistoryappend)rrrrs_authpatprep_rrrr
handle_401s.	$$
	zHTTPDigestAuth.handle_401cCs|j|jjr5|j|j|j|jd<y|jj|j_	Wnt
k
rnd|j_	YnX|jd|j|jd|j
d|j_|S)Nr,responser)r;r2r6rprarbr-rztellr9AttributeError
register_hookrrsr:)rrrrrr s

zHTTPDigestAuth.__call__cCs:t|jt|ddk|jt|ddkgS)Nrr)r'rr(r)rr)rrrr**szHTTPDigestAuth.__eq__cCs||kS)Nr)rr)rrrr+0szHTTPDigestAuth.__ne__N)r!r"r#r$r&r;rprsrr r*r+rrrrr/ls
f,r/)r$r^r}r\rBr0rbase64rcompatrrrcookiesr_internal_utilsrutilsr	CONTENT_TYPE_FORM_URLENCODEDCONTENT_TYPE_MULTI_PARTrobjectrr%r.r/rrrr<module>s$,
Back to Directory File Manager