zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
65
66
67
68
69
70
71
72
U
¡ý°dË'ã@sÊdZddlZddlZddlZddlZddlZddlZddlmZddl    m
Z
ddl m Z m Z mZddlmZddlmZd    Zd
Zd d „ZGd d„dƒZGdd„deƒZGdd„deƒZGdd„deƒZdS)z]
requests.auth
~~~~~~~~~~~~~
 
This module contains the authentication handlers for Requests.
éN)Ú    b64encodeé)Úto_native_string)Ú
basestringÚstrÚurlparse)Úextract_cookies_to_jar)Ú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úDd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\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__HszAuthBase.__call__N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__r!rrrrrEsrc@s0eZdZdZdd„Zdd„Zdd„Zdd    „Zd
S) Ú HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS©N)rr©rrrrrrÚ__init__OszHTTPBasicAuth.__init__cCs(t|jt|ddƒk|jt|ddƒkgƒS©Nrr©ÚallrÚgetattrr©rÚotherrrrÚ__eq__Ss
þÿ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'Ls
r'c@seZdZdZdd„ZdS)Ú HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cCst|j|jƒ|jd<|S)NzProxy-Authorizationr4rrrrr!fszHTTPProxyAuth.__call__Nr"rrrrr6csr6c@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*nszHTTPDigestAuth.__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_statets z$HTTPDigestAuth.init_per_thread_statec sÖ|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|j›7}|j›d|›d|j›}|›d|›}ˆ|ƒ}ˆ|ƒ}||jj    krT|jj
d7_
nd|j_
|jj
d›}t |jj
ƒ  d¡}||  d¡7}|t  ¡  d¡7}|t d¡7}t |¡ ¡dd…}|dkràˆ|›d|›d|›ƒ}|sü| ||›d|›ƒ}nD|dksd| d¡kr<|›d|›d|›d |›}| ||ƒ}ndS||j_    d!|j›d"|›d#|›d$|›d%|›d& }|r„|d'|›d&7}|rš|d(|›d&7}|r°|d)|›d&7}|rÌ|d*|›d+|›d&7}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|›ƒS)Nú:r)ÚsÚd©Ú    hash_utf8rrÚ<lambda>°óz4HTTPDigestAuth.build_digest_header.<locals>.<lambda>ú/ú?rYrZ08xrKééÚauthú,z:auth:z
username="z
", realm="z
", nonce="z", uri="z ", response="ú"z
, opaque="z , algorithm="z
, digest="z, qop="auth", nc=z
, cnonce="zDigest )r:r@ÚgetÚupperrÚpathÚqueryrrr>r?rrÚtimeÚctimeÚosÚurandomrLrSrNÚsplit)rÚmethodÚurlrDrErFrGrHÚ
_algorithmrQrTrVrXÚKDÚentdigÚp_parsedriÚA1ÚA2ÚHA1ÚHA2ÚncvaluerZÚcnonceÚrespdigÚnoncebitÚbaserr\rÚbuild_digest_header~s|   
 
 $ÿ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Úseekr5rgÚlowerÚreÚcompileÚ
IGNORECASEr    Úsubr@ÚcontentÚcloseÚcopyrÚ_cookiesÚrawÚprepare_cookiesrrprqÚ
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>rrprqr5r‰ÚtellrAÚAttributeErrorÚ register_hookržr‚rBrrrrr!szHTTPDigestAuth.__call__cCs(t|jt|ddƒk|jt|ddƒkgƒSr+r,r/rrrr12s
þÿzHTTPDigestAuth.__eq__cCs
||k Sr(rr/rrrr2:szHTTPDigestAuth.__ne__N) r#r$r%r&r*rCrr‚ržr!r1r2rrrrr7ks
n-r7)r&rLrmrŒr8rkrÚbase64rÚ_internal_utilsrÚcompatrrrÚcookiesrÚutilsr    ÚCONTENT_TYPE_FORM_URLENCODEDÚCONTENT_TYPE_MULTI_PARTrrr'r6r7rrrrÚ<module>s$    ,