• File: auth.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/requests/__pycache__/auth.cpython-37.pyc
  • Date Modified: 06/27/2022 11:19 PM
  • File size: 8.12 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

0_'@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|ts&tjd|tdt|}t|tsPtjdt|tdt|}t|trd|d}t|trx|d}dt	t
d||f}|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)usernamepasswordZauthstrr>/opt/alt/python37/lib/python3.7/site-packages/requests/auth.py_basic_auth_strs&






rc@seZdZdZddZdS)AuthBasez4Base class that all auth implementations derive fromcCstddS)NzAuth hooks must be callable.)NotImplementedError)selfrrrr__call__KszAuthBase.__call__N)__name__
__module____qualname____doc__rrrrrrHsrc@s0eZdZdZddZddZddZdd	Zd
S)
HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS)N)rr)rrrrrr__init__RszHTTPBasicAuth.__init__cCs(t|jt|ddk|jt|ddkgS)Nrr)allrgetattrr)rotherrrr__eq__VszHTTPBasicAuth.__eq__cCs
||kS)Nr)rr(rrr__ne__\szHTTPBasicAuth.__ne__cCst|j|j|jd<|S)N
Authorization)rrrheaders)rrrrrr_szHTTPBasicAuth.__call__N)r r!r"r#r%r)r*rrrrrr$Os
r$c@seZdZdZddZdS)
HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cCst|j|j|jd<|S)NzProxy-Authorization)rrrr,)rrrrrrgszHTTPProxyAuth.__call__N)r r!r"r#rrrrrr-dsr-c@sPeZdZdZddZddZddZdd	Zd
dZdd
Z	ddZ
ddZdS)HTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.cCs||_||_t|_dS)N)rr	threadingZlocal
_thread_local)rrrrrrr%oszHTTPDigestAuth.__init__cCs@t|jds<d|j_d|j_d|j_i|j_d|j_d|j_dS)NinitTr)hasattrr0r1
last_noncenonce_countchalpos
num_401_calls)rrrrinit_per_thread_stateusz$HTTPDigestAuth.init_per_thread_statecs|jjd}|jjd}|jjd}|jjd}|jjd}d|dkrTd}n|}|dksl|dkrzd	d
}	|	n@|dkrdd
}
|
n*|dkrdd}|n|dkrdd}|fdd}
dkrdSd}t|}|jpd}|jr|d|j7}d|j||jf}d||f}|}|}||jj	krJ|jj
d7_
nd|j_
d|jj
}t|jj
d}||d7}|t
d7}|td7}t|dd}|dkrЈd|||f}|s|
|d||f}n<|dksd|d kr"d!|||d|f}|
||}ndS||j_	d"|j||||f}|rT|d#|7}|rf|d$|7}|rx|d%|7}|r|d&||f7}d'|S)(z
        :rtype: str
        realmnonceqop	algorithmopaqueNZMD5zMD5-SESScSs"t|tr|d}t|S)Nzutf-8)r
rrhashlibZmd5	hexdigest)xrrrmd5_utf8s

z4HTTPDigestAuth.build_digest_header.<locals>.md5_utf8ZSHAcSs"t|tr|d}t|S)Nzutf-8)r
rrr?sha1r@)rArrrsha_utf8s

z4HTTPDigestAuth.build_digest_header.<locals>.sha_utf8zSHA-256cSs"t|tr|d}t|S)Nzutf-8)r
rrr?Zsha256r@)rArrrsha256_utf8s

z7HTTPDigestAuth.build_digest_header.<locals>.sha256_utf8zSHA-512cSs"t|tr|d}t|S)Nzutf-8)r
rrr?Zsha512r@)rArrrsha512_utf8s

z7HTTPDigestAuth.build_digest_header.<locals>.sha512_utf8csd||fS)Nz%s:%sr)sd)	hash_utf8rr<lambda>z4HTTPDigestAuth.build_digest_header.<locals>.<lambda>/?z%s:%s:%sz%s:%srz%08xzutf-8Zauth,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)r0r6getupperrpathZqueryrrr4r5rrtimeZctimeosurandomr?rCr@split)rmethodurlr:r;r<r=r>Z
_algorithmrBrDrErFZKDZentdigZp_parsedrSZA1ZA2ZHA1ZHA2ZncvaluerGZcnonceZrespdigZnoncebitbaser)rIrbuild_digest_headers~

z"HTTPDigestAuth.build_digest_headercKs|jrd|j_dS)z)Reset num_401_calls counter on redirects.rN)Zis_redirectr0r8)rrkwargsrrrhandle_redirectszHTTPDigestAuth.handle_redirectcKs"d|jkrdks$nd|j_|S|jjdk	rB|jj|jj|jdd}d|	kr|jjdkr|jjd7_t
jd	t
jd
}t
|jd|dd|j_|j||j}t|j|j|j||j||j|j|jd<|jj|f|}|j|||_|Sd|j_|S)
zo
        Takes the given response and tries digest-auth, if needed.

        :rtype: requests.Response
        iirNzwww-authenticater2Zdigestzdigest )flags)countr+)Zstatus_coder0r8r7Zrequestbodyseekr,rQlowerrecompile
IGNORECASEr	subr6ZcontentclosecopyrZ_cookiesrawZprepare_cookiesr[rXrYZ
connectionsendhistoryappend)rrr\Zs_authZpatZprepZ_rrrr
handle_401s.	
zHTTPDigestAuth.handle_401cCs~||jjr&||j|j|jd<y|j|j_	Wnt
k
rTd|j_	YnX|d|j|d|j
d|j_|S)Nr+Zresponser)r9r0r4r[rXrYr,ratellr7AttributeErrorZ
register_hookrnr]r8)rrrrrrszHTTPDigestAuth.__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%r9r[r]rnrr)r*rrrrr.ls
f,r.)r#rUrdrTr?r/rbase64rcompatrrrZcookiesrZ_internal_utilsrZutilsr	ZCONTENT_TYPE_FORM_URLENCODEDZCONTENT_TYPE_MULTI_PARTrobjectrr$r-r.rrrr<module>s$,