7fIQdZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z ddlmZddlmZddlmZmZmZmZmZmZddlmZmZdd lmZmZdd lmZdd l m!Z!dd l"m#Z#m$Z$m%Z%m&Z&m'Z'dd l(m)Z)e!e*Z+da,GddeZ-Gdde Z.Gdde.Z/Gdde.Z0Gdde.Z1e dde2de.fdZ3GddeZ4dS)zNetwork Authentication Helpers Contains interface (MultiDomainBasicAuth) and associated glue code for providing credentials in the context of network requests. N)ABCabstractmethod) lru_cache) commonprefix)Path)AnyDictList NamedTupleOptionalTuple)AuthBase HTTPBasicAuth)RequestResponse)get_netrc_auth) getLogger)ask ask_input ask_passwordremove_auth_from_urlsplit_auth_netloc_from_url)AuthInfoFc.eZdZUeed<eed<eed<dS) CredentialsurlusernamepasswordN)__name__ __module__ __qualname__str__annotations__z/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/network/auth.pyrr's+ HHHMMMMMMMMr%rc eZdZUdZeed<ededeedee fdZ ededededdfd Z dS) KeyRingBaseProviderzKeyring base provider interface has_keyringrrreturncdSNr$selfrrs r& get_auth_infoz!KeyRingBaseProvider.get_auth_info2s !Sr%rNcdSr,r$r.rrrs r&save_auth_infoz"KeyRingBaseProvider.save_auth_info7sNQcr%) rr r!__doc__boolr#rr"r rr/r2r$r%r&r(r(-s))!!"*3-! ( !!!^!Q#QQQQQQ^QQQr%r(cZeZdZdZdZdedeedeefdZdedededdfd Z dS) KeyRingNullProviderzKeyring null providerFrrr*cdSr,r$r-s r&r/z!KeyRingNullProvider.get_auth_info@tr%rNcdSr,r$r1s r&r2z"KeyRingNullProvider.save_auth_infoCr8r%) rr r!r3r)r"r rr/r2r$r%r&r6r6;sK (8BT#r%r6cbeZdZdZdZd dZdedeedeefdZ deded eddfd Z dS) KeyRingPythonProviderz7Keyring interface which uses locally imported `keyring`Tr*Ncddl}||_dS)Nrkeyring)r.r>s r&__init__zKeyRingPythonProvider.__init__Ls r%rrc<t|jdrHtd||j||}||j|jfSdS|loggerdebugrArr get_password)r.rrcredrs r&r/z#KeyRingPythonProvider.get_auth_infoQs 4|j|||dSr,)r> set_passwordr1s r&r2z$KeyRingPythonProvider.save_auth_infocs" !!#x:::::r%)r*N) rr r!r3r)r?r"r rr/r2r$r%r&r;r;GsAAK  (8BT$;#;;;;;;;;;r%r;ceZdZdZdZdeddfdZdedeedeefd Z deded eddfd Z d ededeefd Z d eded eddfdZ dS)KeyRingCliProviderzProvider which uses `keyring` cli Instead of calling the keyring package installed alongside pip we call keyring on the command line which will enable pip to use which ever installation of keyring is available first in PATH. Tcmdr*Nc||_dSr,r=)r.rKs r&r?zKeyRingCliProvider.__init__rs  r%rrcB||||}|||fSdSr,) _get_passwordr1s r&r/z KeyRingCliProvider.get_auth_infous5  ))#x88H#))tr%rc0||||Sr,) _set_passwordr1s r&r2z!KeyRingCliProvider.save_auth_info~s!!#x:::r% service_namecH|jdS|jd||g}tj}d|d<t j|tjtj|}|jrdS|j d tj S)z;Mirror the implementation of keyring.get_password using cliNgetutf-8PYTHONIOENCODING)stdinstdoutenv) r>osenvironcopy subprocessrunDEVNULLPIPE returncoderWdecodestriplinesep)r.rQrrKrXress r&rNz KeyRingCliProvider._get_passwords < 4|UL(;joo") n $?     > 4z  ))// ;;;r%c|jdStj}d|d<t j|jd||g|tj|ddS)z;Mirror the implementation of keyring.set_password using cliNrTrUsetT)inputrXcheck)r>rYrZr[r\r]rcencode)r.rQrrrXs r&rPz KeyRingCliProvider._set_passwords{ < 4joo")  \5, 9+rz++2244     tr%) rr r!r3r)r"r?r rr/r2rNrPr$r%r&rJrJgsKCD (8BT;#;;;;;;;<#<<#<<<<$ #   PT      r%rJ)maxsizeproviderr*ctd|trd}|dvr t}td|S#t$rYnbt $rV}d}|dkr|dz}t||ttj Yd}~nd}~wwxYw|d vrStj d }|r| tjd rtjd t"fd }t%tjd }g}|t(jD]L}t%|} | |s||=#t0$rYIwxYwt(j|}tj d |}|r*td|t5|Stdt7S)NzKeyring provider requested: %sdisabled)importautozKeyring provider set: importz1Installed copy of keyring fails with exception %sroz3, trying to find a keyring executable as a fallbackexc_info)r\ror>scriptsr*ctjdd}|9 tjd}n##tt f$rtj}YnwxYw|S)NPATHCS_PATH)rYrZrSconfstrAttributeError ValueErrordefpathpaths r&"PATH_as_shutil_which_determines_itz@get_keyring_provider..PATH_as_shutil_which_determines_itsdz~~fd33<*!z)44*J7***!z*  s9AArzz3Keyring provider set: subprocess with executable %szKeyring provider set: disabled)rCverboseKEYRING_DISABLEDr; ImportError Exceptionwarning isEnabledForloggingDEBUGshutilwhich startswith sysconfigget_pathtyping no_type_checkr"rsplitrYpathsepsamefileappendFileNotFoundErrorjoinrJr6) rkimplexcmsgclir|rrpathsr{ps r&get_keyring_providerrsh NN3X>>>%%% R(**D NN9 : : :K    D R R RFC6!!QQ NN3f.A.A'-.P.PN Q Q Q Q Q Q Q Q  R)))l9%%  53>>)"4Y"?"?@@ 5  !    " ! 9-i8899GE::<<BB2:NN  JJ::g..+ T***(D:??5))D,yt444C  + NNPRU V V V%c** * NN3444   s0)A B? B?)A B::B?>*F)) F65F6c eZdZ d"dedeeededdfdZede fd Z e j d eddfd Z edefd Z d eedeedee fdZd edeefdZddddededede fdZdedeeeeeeffdZdedefdZdedeeeeeeffdZdefdZdededefdZdededdfd Zdededdfd!ZdS)#MultiDomainBasicAuthTNro prompting index_urlskeyring_providerr*cL||_||_||_i|_d|_dSr,)rrr passwords_credentials_to_save)r.rrrs r&r?zMultiDomainBasicAuth.__init__s2 #$ 0.0 <@!!!r%c*t|jSr,)r_keyring_providerr.s r&rz%MultiDomainBasicAuth.keyring_providers#D$:;;;r%rkc||_dSr,)r)r.rks r&rz%MultiDomainBasicAuth.keyring_providers "*r%c"|jp|jdvS)N)rorm)rrrs r& use_keyringz MultiDomainBasicAuth.use_keyrings ~S!7?S!SSr%rrc0|sdS |j||S#t$rj}tddtdt |dat Yd}~dSd}~wwxYw)z3Return the tuple auth for a given url from keyring.Nz&Keyring is skipped due to an exceptionTrpz*Keyring is skipped due to an exception: %s) rr/rrCrDrr"r~r cache_clear)r.rrrs r&_get_keyring_authz&MultiDomainBasicAuth._get_keyring_auths 4 (66sHEE E    LLADL Q Q Q NN<C    $  , , . . .44444 s! BABBcf|r|jsdSt|ddz}tj|g}|jD]}|ddz}tjt|}|kr|cSj|jkratj|}|||sdS|dfdtj |dS)aReturn the original index URL matching the requested URL. Cached or dynamically generated credentials may work against the original index URL rather than just the netloc. The provided url should have had its username and password removed already. If the original index url had credentials then they will be included in the return value. Returns None if no matching index was found, or if --no-index was specified by the user. N/Tc`tj|jgdS)Nr)rr{rfind) candidate parsed_urls r&z5MultiDomainBasicAuth._get_index_url..Es0,ON## eCjj r%)reversekeyr) rrrstripurllibparseurlsplitnetlocrsort urlunsplit)r.r candidatesindex parsed_indexrrs @r&_get_index_urlz#MultiDomainBasicAuth._get_index_urlsI $/ 4"3''..s33c9\**3//  _ ) )ELL%%+E!<001Ee1L1LMML\))  L$777 --e44I   i ( ( ( ( 4    |&&z!}555r%F allow_netrc allow_keyring original_urlrrcht|\}}}|\}}||td||S||} | r2t| } | r!| \} } } td| | r.| d&| \}}||td|| S|r.t |} | rtd|| S|rK|| |p|||}|rtd||S||fS)z2Find and return credentials for the specified URL.NzFound credentials in url for %szFound index url %srz%Found credentials in index url for %sz!Found credentials in netrc for %sz#Found credentials in keyring for %s)rrCrDrrr)r.rrrrrurl_user_passwordrr index_url index_info_index_url_user_password netrc_authkr_auths r&_get_new_credentialsz)MultiDomainBasicAuth._get_new_credentialsOs*D * * &V& /(  H$8 LL:F C C C$ $'',,  >3I>>J >8B5 15 19===  /03?!8 Hh#(< DfMMM..  "' 55J " @&III!!  &&y(;;9&&vx88    BFKKK!!r%ct|\}}}||\}}||%||jvr|j|\}}|||kr||}}|||pd}|pd}||f|j|<|||| Jd||||fS)a_Return the credentials to use for the provided URL. If allowed, netrc and keyring may be used to obtain the correct credentials. Returns (url_without_credentials, username, password). Note that even if the original URL contains credentials, this function may return a different username and password. Nz%Could not load credentials from url: )rrr) r.rrrrrrunpws r&_get_url_and_credentialsz-MultiDomainBasicAuth._get_url_and_credentialss4LAAVQ"66|DD(   0f6N6N^F+FB8r>>%'(  8#7  ~2H~2H'/%9DN6 " !h&: X%5%5 A< A A&6%5 7 Hh&&r%reqc||j\}}}||_||t|||}|d|j|S)Nresponse)rrr register_hook handle_401)r.rrrrs r&__call__zMultiDomainBasicAuth.__call__sj"&"?"?"H"HXx  H$83-(33C88C *do666 r%rc|jrtd|dnd}|sdS|jr9|||}|r!|d|d|d|ddfSt d}||dfS) Nz User for z: )NNFrFz Password: T)rrrrr)r.rrauthrs r&_prompt_for_passwordz)MultiDomainBasicAuth._prompt_for_passwords9=P93333444D %$$   /))&(;;D /Q+Q0CAwQ.. --4''r%cf|jr|jr |jjsdSt dddgdkS)NFz#Save credentials to keyring [y/N]: yn)rrrr)rrs r& _should_save_password_to_keyringz5MultiDomainBasicAuth._should_save_password_to_keyringsH # (4  583*EELLr%respkwargsc |jdkr|Sd\}}|jr ||jdd\}}|js|s|s|St j|j}d}|s |s||j \}}}d|_ |E|C||f|j |j <|r0| rt|j |||_ |j}|jt#|pd|pd|j}|d|j|j r|d|j|jj|fi|} | j|| S) N)NNFTr)rrrrr) status_coderrrrrrurlparserrrrrrcontentraw release_connrrequestr warn_on_401save_credentials connectionsendhistoryr) r.rrrrparsedsaverrnew_resps r&rzMultiDomainBasicAuth.handle_401s  s " "K'(   !%!:!:!"";"" Hh~ h x K&&tx00 P P'+'@'@'O'O $Hh%)!  H$8-5x,@DN6= ) ==?? ,7 %%---) L >>>>> ?  ? ?++sAA::$B"!B")TNro)rr r!r4r r r"r?propertyr(rsetterrrrrrr rrrrrrrrrrr$r%r&rrs*. & @@@T#Y'@ @  @@@@"<"5<<<X<******TTTTTXT  c]3- (  4.6#.6(3-.6.6.6.6h!# 7"7"7"7" 7"  7"  7"7"7"7"r.'.' sHSM8C=0 1.'.'.'.'`G" ( ( x}hsmT1 2 ( ( ( (M$MMMM=x=3=8====~CD?X????????r%r)5r3rrYrr\rr urllib.parserabcrr functoolsros.pathrpathlibrrr r r r r pip._vendor.requests.authrrpip._vendor.requests.modelsrrpip._vendor.requests.utilsrpip._internal.utils.loggingrpip._internal.utils.miscrrrrr pip._internal.vcs.versioncontrolrrrCr~rr(r6r;rJr"rrr$r%r&rs   ######## ????????????????========99999999555555111111655555 8  * R R R R R# R R R     -   ;;;;;/;;;@88888,888v 4:!3:!+>:!:!:!:!zV?V?V?V?V?8V?V?V?V?V?r%