zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
U
I=®dß'ã@sÌdZddlZddlZddlZddlZddlZddlZddlmZddl    m
Z
m Z m Z ddl mZddlmZddlmZd    Zd
Zd d „ZGd d„deƒZGdd„deƒZGdd„deƒZGdd„deƒZdS)z]
requests.auth
~~~~~~~~~~~~~
 
This module contains the authentication handlers for Requests.
éN)Ú    b64encodeé)ÚurlparseÚstrÚ
basestring)Úextract_cookies_to_jar)Úto_native_string)Úparse_dict_headerz!application/x-www-form-urlencodedzmultipart/form-datacCsšt|tƒs&tjd |¡tdt|ƒ}t|tƒsPtjd t|ƒ¡tdt|ƒ}t|tƒrd| d¡}t|tƒrx| d¡}dt    t
d  ||f¡ƒ  ¡ƒ}|S)zReturns a Basic Auth string.z·Non-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.)Úcategoryz·Non-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 ó:) Ú
isinstancerÚwarningsÚwarnÚformatÚDeprecationWarningrÚtypeÚencoderrÚjoinÚstrip)ÚusernameÚpasswordÚauthstr©rúPD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/requests/auth.pyÚ_basic_auth_strs0
 
ýû
ýû
 
 
 
ÿrc@seZdZdZdd„ZdS)ÚAuthBasez4Base class that all auth implementations derive fromcCs tdƒ‚dS)NzAuth hooks must be callable.)ÚNotImplementedError©ÚselfÚrrrrÚ__call__KszAuthBase.__call__N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__r!rrrrrHsrc@s0eZdZdZdd„Zdd„Zdd„Zdd    „Zd
S) Ú HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS©N)rr©rrrrrrÚ__init__RszHTTPBasicAuth.__init__cCs(t|jt|ddƒk|jt|ddƒkgƒS©Nrr©ÚallrÚgetattrr©rÚotherrrrÚ__eq__VsþzHTTPBasicAuth.__eq__cCs
||k Sr(rr/rrrÚ__ne__\szHTTPBasicAuth.__ne__cCst|j|jƒ|jd<|S)NÚ Authorization©rrrÚheadersrrrrr!_szHTTPBasicAuth.__call__N)r#r$r%r&r*r1r2r!rrrrr'Os
r'c@seZdZdZdd„ZdS)Ú HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cCst|j|jƒ|jd<|S)NzProxy-Authorizationr4rrrrr!gszHTTPProxyAuth.__call__Nr"rrrrr6dsr6c@sPeZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dd„Z dS)ÚHTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.cCs||_||_t ¡|_dSr()rrÚ    threadingÚlocalÚ _thread_localr)rrrr*oszHTTPDigestAuth.__init__cCs@t|jdƒs<d|j_d|j_d|j_i|j_d|j_d|j_dS)NÚinitTÚr)Úhasattrr:r;Ú
last_nonceÚ nonce_countÚchalÚposÚ num_401_calls)rrrrÚinit_per_thread_stateus z$HTTPDigestAuth.init_per_thread_statecs–|jjd}|jjd}|jj d¡}|jj d¡}|jj d¡}d‰|dkrTd}n| ¡}|dksl|dkrzd    d
„}    |    ‰n@|d krd d „}
|
‰n*|dkr¦dd„} | ‰n|dkrºdd„} | ‰‡fdd„} ˆdkrÒdSd}t|ƒ}|jpæd}|jrü|d|j7}d|j||jf}d||f}ˆ|ƒ}ˆ|ƒ}||jj    krJ|jj
d7_
nd|j_
d|jj
}t |jj
ƒ  d¡}||  d¡7}|t  ¡  d¡7}|t d¡7}t |¡ ¡dd…}|dkrЈd|||fƒ}|sê| |d||fƒ}n<|dksd| d ¡kr"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
        ÚrealmÚnonceÚqopÚ    algorithmÚopaqueNÚMD5zMD5-SESScSs"t|tƒr| d¡}t |¡ ¡S©Núutf-8)r rrÚhashlibÚmd5Ú    hexdigest©ÚxrrrÚmd5_utf8‘s
 
z4HTTPDigestAuth.build_digest_header.<locals>.md5_utf8ÚSHAcSs"t|tƒr| d¡}t |¡ ¡SrJ)r rrrLÚsha1rNrOrrrÚsha_utf8—s
 
z4HTTPDigestAuth.build_digest_header.<locals>.sha_utf8zSHA-256cSs"t|tƒr| d¡}t |¡ ¡SrJ)r rrrLÚsha256rNrOrrrÚ sha256_utf8s
 
z7HTTPDigestAuth.build_digest_header.<locals>.sha256_utf8zSHA-512cSs"t|tƒr| d¡}t |¡ ¡SrJ)r rrrLÚsha512rNrOrrrÚ sha512_utf8£s
 
z7HTTPDigestAuth.build_digest_header.<locals>.sha512_utf8csˆd||fƒS)Nú%s:%sr)ÚsÚd©Ú    hash_utf8rrÚ<lambda>©óz4HTTPDigestAuth.build_digest_header.<locals>.<lambda>ú/ú?z%s:%s:%srYrz%08xrKééÚauthú,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)r:r@ÚgetÚupperrÚpathÚqueryrrr>r?rrÚtimeÚctimeÚosÚurandomrLrSrNÚsplit)rÚmethodÚurlrDrErFrGrHÚ
_algorithmrQrTrVrXÚKDÚentdigÚp_parsedrhÚA1ÚA2ÚHA1ÚHA2ÚncvaluerZÚcnonceÚrespdigÚnoncebitÚbaserr\rÚbuild_digest_headersŠ   
 
ÿ ÿ   z"HTTPDigestAuth.build_digest_headercKs|jrd|j_dS)z)Reset num_401_calls counter on redirects.rN)Ú is_redirectr:rB)rr ÚkwargsrrrÚhandle_redirectåszHTTPDigestAuth.handle_redirectcKs"d|jkrdks$nd|j_|S|jjdk    rB|jj |jj¡|j dd¡}d|     ¡kr|jjdkr|jjd7_t
j d    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
        iiôrNzwww-authenticater<Údigestézdigest )Úflags)Úcountr3)Ú status_coder:rBrAÚrequestÚbodyÚseekr5rfÚlowerÚreÚcompileÚ
IGNORECASEr    Úsubr@ÚcontentÚcloseÚcopyrÚ_cookiesÚrawÚprepare_cookiesr~rorpÚ
connectionÚsendÚhistoryÚappend)rr r€Ús_authÚpatÚprepÚ_rrrrÚ
handle_401ês2     
 ÿ
 zHTTPDigestAuth.handle_401cCs~| ¡|jjr&| |j|j¡|jd<z|j ¡|j_    Wnt
k
rTd|j_    YnX|  d|j ¡|  d|j ¡d|j_|S)Nr3Úresponser)rCr:r>r~rorpr5rˆÚtellrAÚAttributeErrorÚ register_hookrrrBrrrrr!szHTTPDigestAuth.__call__cCs(t|jt|ddƒk|jt|ddƒkgƒSr+r,r/rrrr1*sþzHTTPDigestAuth.__eq__cCs
||k Sr(rr/rrrr20szHTTPDigestAuth.__ne__N) r#r$r%r&r*rCr~rrr!r1r2rrrrr7ls
f,r7)r&rlr‹rjrLr8rÚbase64rÚcompatrrrÚcookiesrÚ_internal_utilsrÚutilsr    ÚCONTENT_TYPE_FORM_URLENCODEDÚCONTENT_TYPE_MULTI_PARTrÚobjectrr'r6r7rrrrÚ<module>s$    ,