kf'dZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z ddl mZddlmZddlmZd Zd Zd ZGd d eZGddeZGddeZGddeZdS)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-datac t|ts=tjd|t t |}t|tsJtjdt|t t |}t|t r|d}t|t r|d}dttd ||f z}|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 :) isinstancerwarningswarnformatDeprecationWarningrtypeencoder rjoinstrip)usernamepasswordauthstrs m/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/requests/auth.py_basic_auth_strrs6 h + +!  x(('     x== h + +!  tH~~..'     x==(C  -??8,,(C  -??8,,)$))Xx0112288::G NceZdZdZdZdS)AuthBasez4Base class that all auth implementations derive fromc td)NzAuth hooks must be callable.)NotImplementedErrorselfrs r__call__zAuthBase.__call__Ks!"@AAArN__name__ __module__ __qualname____doc__r%rrrrHs.>>BBBBBrrc*eZdZdZdZdZdZdZdS) HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.c"||_||_dSN)rrr#rrs r__init__zHTTPBasicAuth.__init__Rs    rc t|jt|ddk|jt|ddkgSNrrallrgetattrrr#others r__eq__zHTTPBasicAuth.__eq__VE MWUJ== = MWUJ== =    rc||k Sr/r+r7s r__ne__zHTTPBasicAuth.__ne__\5=  rcJt|j|j|jd<|S)N Authorizationrrrheadersr"s rr%zHTTPBasicAuth.__call___s!%4T]DM%R%R /"rN)r'r(r)r*r1r9r<r%r+rrr-r-OsVII!!!   !!!rr-ceZdZdZdZdS) HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cJt|j|j|jd<|S)NzProxy-Authorizationr@r"s rr%zHTTPProxyAuth.__call__gs"+:4=$-+X+X '(rNr&r+rrrCrCds)GGrrCcBeZdZdZdZdZdZdZdZdZ dZ d Z d S) HTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.cR||_||_tj|_dSr/)rr threadinglocal _thread_localr0s rr1zHTTPDigestAuth.__init__os&    &_..rct|jdsJd|j_d|j_d|j_i|j_d|j_d|j_dSdS)NinitTr)hasattrrJrL last_nonce nonce_countchalpos num_401_calls)r#s rinit_per_thread_statez$HTTPDigestAuth.init_per_thread_stateusit)622 4&*D  #,.D  )-.D  *&(D  #%)D  "/3D  , , ,  4 4rc |jjd}|jjd}|jjd}|jjd}|jjd}d|d}n|}|dks|dkrd } | n#|d krd } | n|d krd } | n |dkrd} | fd} dSd}t |}|jpd}|jr |d|jzz }|jd|d|j}|d|}|}|}||jj kr|jxj dz c_ n d|j_ d|jj z}t|jj  d}|| dz }|tj dz }|tjdz }t#j|dd}|dkr|d|d|}|s| ||d|}n<|dksd|dvr|d|d|ddd| }| ||}ndS||j_ d|jd|d|d|d|d }|r|d!|zz }|r|d"|zz }|r|d#|zz }|r |d$|d%|d z }d&|zS)'z :rtype: str realmnonceqop algorithmopaqueNMD5zMD5-SESSct|tr|d}tj|SNutf-8)rrrhashlibmd5 hexdigestxs rmd5_utf8z4HTTPDigestAuth.build_digest_header..md5_utf8s?a%%*))A{1~~//111rSHAct|tr|d}tj|Sr])rrrr_sha1rarbs rsha_utf8z4HTTPDigestAuth.build_digest_header..sha_utf8s?a%%*))A|A00222rzSHA-256ct|tr|d}tj|Sr])rrrr_sha256rarbs r sha256_utf8z7HTTPDigestAuth.build_digest_header..sha256_utf8Aa%%*))A~a((22444rzSHA-512ct|tr|d}tj|Sr])rrrr_sha512rarbs r sha512_utf8z7HTTPDigestAuth.build_digest_header..sha512_utf8rlrc$|d|S)N:r+)sd hash_utf8s rz4HTTPDigestAuth.build_digest_header..s))qqq!!$455r/?rqrz%08xr^auth,z username="z ", realm="z ", nonce="z", uri="z ", response=""z , opaque="%s"z, algorithm="%s"z , digest="%s"z, qop="auth", nc=z , cnonce="z Digest %s)rJrQgetupperrpathqueryrrrOrPrrtimectimeosurandomr_rgrasplit)r#methodurlrVrWrXrYrZ _algorithmrdrhrkroKDentdigp_parsedrA1A2HA1HA2ncvaluerrcnoncerespdignoncebitbaserts @rbuild_digest_headerz"HTTPDigestAuth.build_digest_headers "'0"'0 %))%00&+// << #(,,X66  JJ"**J   * ":": 2 2 2!II 5  3 3 3!II 9 $ $ 5 5 5$II 9 $ $ 5 5 5$I 5 5 5 5  4C==}# > ) C(.( (D===%%% ? %immimm D&1 1 1   * *a / * * *-.D  *4-99 ". / / 6 6w ? ? U\\' " "" TZ\\  ) )) RZ]],q//++--crc2  # #)###uuuff=>>C b455GG F]]f #66wwwHbh''GG4(-%%#'---tttWWWN  - Of, ,D  3 &2 2D  - Of, ,D  K D'''666J JDd##rc 0|jrd|j_dSdS)z)Reset num_401_calls counter on redirects.rN) is_redirectrJrS)r#r$kwargss rhandle_redirectzHTTPDigestAuth.handle_redirects' = 1/0D  , , , 1 1rc d|jcxkrdksnd|j_|S|jj)|jj|jj|jdd}d| vrA|jjdkr0|jxjdz c_tj d tj }t|d|d |j_|j||j}t'|j|j|j||j||j|j|jd <|jj|fi|}|j|||_|Sd|j_|S) zo Takes the given response and tries digest-auth, if needed. :rtype: requests.Response iirNzwww-authenticaterMdigestzdigest )flags)countr?) status_coderJrSrRrequestbodyseekrAr}lowerrecompile IGNORECASEr subrQcontentclosecopyr_cookiesrawprepare_cookiesrrr connectionsendhistoryappend)r#r$rs_authpatprep_rs r handle_401zHTTPDigestAuth.handle_401sam))))c))))/0D  ,H   ! - IN   2 6 7 7 71266 v||~~ % %$*<*JQ*N*N   , , 1 , ,*Zr}===C&7FRS8T8T&U&UD  # II GGIII9>>##D "4=!)QU C C C   / / /,0,D,D TX-'-'DL )""422622B J  a BJI+,(rc||jjr(||j|j|jd< |j|j_ n#t$rd|j_ YnwxYw| d|j | d|j d|j_|S)Nr?responser)rTrJrOrrrrArtellrRAttributeError register_hookrrrSr"s rr%zHTTPDigestAuth.__call__s ""$$$   ( S)-)A)A!(AE)R)RAIo & *%&V[[]]D  " " * * * &*D  " " "  *  DO444  D$8999+,(s #A..BBc t|jt|ddk|jt|ddkgSr3r4r7s rr9zHTTPDigestAuth.__eq__*r:rc||k Sr/r+r7s rr<zHTTPDigestAuth.__ne__0r=rN) r'r(r)r*r1rTrrrr%r9r<r+rrrFrFlsJJ/// 444d$d$d$L111 ***X(   !!!!!rrF)r*rrrr_rHrbase64rcompatrrrcookiesr_internal_utilsr utilsr CONTENT_TYPE_FORM_URLENCODEDCONTENT_TYPE_MULTI_PARTrobjectrr-rCrFr+rrrs ----------++++++------$$$$$$B/)))XBBBBBvBBBH*ME!E!E!E!E!XE!E!E!E!E!r