f'dZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZddlmZddlmZd Zd Zd ZGd d ZGddeZGddeZGddeZy)z] requests.auth ~~~~~~~~~~~~~ This module contains the authentication handlers for Requests. N) b64encode)to_native_string) basestringstrurlparse)extract_cookies_to_jar)parse_dict_headerz!application/x-www-form-urlencodedzmultipart/form-datac t|ts5tjdj |t t |}t|ts>tjdj t|t t |}t|t r|jd}t|t r|jd}dttdj||fjz}|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)usernamepasswordauthstrs V/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/requests/auth.py_basic_auth_strrs h +  x('  x= h +  tH~.'  x=(C ??8,(C ??8,)$))Xx01288:G NceZdZdZdZy)AuthBasez4Base class that all auth implementations derive fromctd)NzAuth hooks must be callable.)NotImplementedErrorselfrs r__call__zAuthBase.__call__Hs!"@AArN__name__ __module__ __qualname____doc__r%rrrrEs >Brrc(eZdZdZdZdZdZdZy) HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.c ||_||_yN)rrr#rrs r__init__zHTTPBasicAuth.__init__Os    rc |t|jt|ddk(|jt|ddk(gSNrrallrgetattrrr#others r__eq__zHTTPBasicAuth.__eq__S>  D!AA  D!AA   rc||k( Sr/r+r7s r__ne__zHTTPBasicAuth.__ne__[5=  rc`t|j|j|jd<|S)N Authorizationrrrheadersr"s rr%zHTTPBasicAuth.__call__^s$%4T]]DMM%R /"rN)r'r(r)r*r1r9r<r%r+rrr-r-LsI! !rr-ceZdZdZdZy) HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.c`t|j|j|jd<|S)NzProxy-Authorizationr@r"s rr%zHTTPProxyAuth.__call__fs%+:4==$--+X '(rNr&r+rrrCrCcs GrrCc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) HTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.cR||_||_tj|_yr/)rr threadinglocal _thread_localr0s rr1zHTTPDigestAuth.__init__ns    &__.rct|jdsgd|j_d|j_d|j_i|j_d|j_d|j_yy)NinitTr)hasattrrJrL last_nonce nonce_countchalpos num_401_calls)r#s rinit_per_thread_statez$HTTPDigestAuth.init_per_thread_statetskt))62&*D   #,.D   )-.D   *&(D   #%)D   "/3D   , 3rc B|jjd}|jjd}|jjjd}|jjjd}|jjjd}d|d}n|j}|dk(s|dk(rd } | n |d k(rd } | n|d k(rd } | n |dk(rd} | fd} yd}t |}|j xsd}|j r|d|j z }|jd|d|j}|d|}|}|}||jjk(r |jxjdz c_ nd|j_ |jjd}t|jjjd}||jdz }|tjjdz }|tj dz }t#j$|j'dd}|dk(r|d|d|}|s| ||d|}n0|dk(sd|j)dvr|d|d|d|}| ||}ny||j_ d|jd|d|d|d |d! }|r |d"|d!z }|r |d#|d!z }|r |d$|d!z }|r |d%|d&|d!z }d'|S)(z :rtype: str realmnonceqop algorithmopaqueNMD5zMD5-SESSct|tr|jd}tj|j SNutf-8)rrrhashlibmd5 hexdigestxs rmd5_utf8z4HTTPDigestAuth.build_digest_header..md5_utf8s1a%)A{{1~//11rSHAct|tr|jd}tj|j Sr])rrrr_sha1rarbs rsha_utf8z4HTTPDigestAuth.build_digest_header..sha_utf8s1a%)A||A0022rzSHA-256ct|tr|jd}tj|j Sr])rrrr_sha256rarbs r sha256_utf8z7HTTPDigestAuth.build_digest_header..sha256_utf82a%)A~~a(2244rzSHA-512ct|tr|jd}tj|j Sr])rrrr_sha512rarbs r sha512_utf8z7HTTPDigestAuth.build_digest_header..sha512_utf8rlrc|d|S)N:r+)sd hash_utf8s rz4HTTPDigestAuth.build_digest_header..s)qc1#J/r/?rqr08xr^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 )rJrQgetupperrpathqueryrrrOrPrrtimectimeosurandomr_rgrasplit)r#methodurlrVrWrXrYrZ _algorithmrdrhrkroKDentdigp_parsedrA1A2HA1HA2ncvaluerrcnoncerespdignoncebitbaserts @rbuild_digest_headerz"HTTPDigestAuth.build_digest_header~s ""''0""''0  %%))%0&&++// < ##((,,X6  J"*J  * ": 2 !I 5  3 !I 9 $ 5 $I 9 $ 5 $I /  C=}}# >> a'( (D awa  7xq mm D&&11 1    * *a / *-.D   *''33C8 "".. / 6 6w ? U\\' "" TZZ\  )) RZZ]a**,Sb1  #se1UG1VH56Cq./G F]f #6'!F86#?Hh'G(-%z% 5'J6wiq 2   j* *D  mI;a0 0D  j* *D  'y 6(!D DDrc @|jrd|j_yy)z)Reset num_401_calls counter on redirects.rN) is_redirectrJrS)r#r$kwargss rhandle_redirectzHTTPDigestAuth.handle_redirects ==/0D   , rc ld|jcxkrdksnd|j_|S|jj9|jj j |jj|jjdd}d|jvrz|jjdkr`|jxjdz c_tjdtj }t|jd|d |j_|j |j#|jj%}t'|j(|j|j*|j-|j(|j/|j0|j2|jd <|j4j6|fi|}|j8j;|||_|Sd|j_|S) zo Takes the given response and tries digest-auth, if needed. :rtype: requests.Response iirzwww-authenticaterMdigestzdigest )flags)countr?) status_coderJrSrRrequestbodyseekrAr~lowerrecompile IGNORECASEr subrQcontentclosecopyr _cookiesrawprepare_cookiesrrr connectionsendhistoryappend)r#r$rs_authpatprep_rs r handle_401zHTTPDigestAuth.handle_401samm)c)/0D   ,H    ! ! - IINN   2 2 6 6 7126 v||~ %$*<*<*J*JQ*N    , , 1 ,**Zr}}=C&7FRS8T&UD   # II GGI99>>#D "4==!))QUU C   /,0,D,D TXX-DLL )#""4262B JJ  a BJI+,(rc|j|jjr3|j|j|j |j d< |jj|j_ |jd|j|jd|jd|j_|S#t$rd|j_ YgwxYw)Nr?responser)rTrJrOrrrrArtellrRAttributeError register_hookrrrSr"s rr%zHTTPDigestAuth.__call__s ""$    ( ()-)A)A!((AEE)RAIIo & *%&VV[[]D   "  DOO4  D$8$89+,( * &*D   "  *s)CC,+C,c |t|jt|ddk(|jt|ddk(gSr3r4r7s rr9zHTTPDigestAuth.__eq__1r:rc||k( Sr/r+r7s rr<zHTTPDigestAuth.__ne__9r=rN) r'r(r)r*r1rTrrrr%r9r<r+rrrFrFks0J/ 4l \1 *X( !rrF)r*r_rrrHrrbase64r_internal_utilsrcompatrrrcookiesr utilsr CONTENT_TYPE_FORM_URLENCODEDCONTENT_TYPE_MULTI_PARTrrr-rCrFr+rrrst  ---+$B/)XBBH.MO!XO!r