
    q"hIQ                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
Jr  SSKJr  SSKJr  SSKJr  SSKJrJrJrJrJrJr  SSKJrJr  SS	KJrJr  SS
KJr  SSK J!r!  SSK"J#r#J$r$J%r%J&r&J'r'  SSK(J)r)  \!" \*5      r+Sq, " S S\5      r- " S S\
5      r. " S S\.5      r/ " S S\.5      r0 " S S\.5      r1\" SS9S\2S\.4S j5       r3 " S S\5      r4g)zNetwork Authentication Helpers

Contains interface (MultiDomainBasicAuth) and associated glue code for
providing credentials in the context of network requests.
    N)ABCabstractmethod)	lru_cache)commonprefix)Path)AnyDictList
NamedTupleOptionalTuple)AuthBaseHTTPBasicAuth)RequestResponse)get_netrc_auth)	getLogger)ask	ask_inputask_passwordremove_auth_from_urlsplit_auth_netloc_from_url)AuthInfoFc                   4    \ rS rSr% \\S'   \\S'   \\S'   Srg)Credentials'   urlusernamepassword N)__name__
__module____qualname____firstlineno__str__annotations____static_attributes__r        L/var/www/html/env/lib/python3.13/site-packages/pip/_internal/network/auth.pyr   r   '   s    	HMMr(   r   c            	       t    \ rS rSr% Sr\\S'   \S\S\	\   S\	\
   4S j5       r\S\S\S\SS	4S
 j5       rSrg	)KeyRingBaseProvider-   zKeyring base provider interfacehas_keyringr   r   returnc                     g Nr    selfr   r   s      r)   get_auth_info!KeyRingBaseProvider.get_auth_info2   s     !r(   r   Nc                     g r0   r    r2   r   r   r   s       r)   save_auth_info"KeyRingBaseProvider.save_auth_info7   s    NQr(   r    )r!   r"   r#   r$   __doc__boolr&   r   r%   r   r   r3   r7   r'   r    r(   r)   r+   r+   -   sb    )!!"*3-!	(	! ! Q#QQQQ Qr(   r+   c                   X    \ rS rSrSrSrS\S\\   S\\   4S jr	S\S\S\SS	4S
 jr
Srg	)KeyRingNullProvider;   zKeyring null providerFr   r   r.   c                     g r0   r    r1   s      r)   r3   !KeyRingNullProvider.get_auth_info@       r(   r   Nc                     g r0   r    r6   s       r)   r7   "KeyRingNullProvider.save_auth_infoC   r@   r(   r    )r!   r"   r#   r$   r9   r-   r%   r   r   r3   r7   r'   r    r(   r)   r<   r<   ;   sN    K  (8BT #    r(   r<   c                   b    \ rS rSrSrSrSS jrS\S\\   S\\	   4S	 jr
S\S\S
\SS4S jrSrg)KeyRingPythonProviderG   z7Keyring interface which uses locally imported `keyring`Tr.   Nc                     SS K nXl         g )Nr   keyring)r2   rH   s     r)   __init__KeyRingPythonProvider.__init__L   s
    r(   r   r   c                 P   [        U R                  S5      (       aM  [        R                  SU5        U R                  R	                  X5      nUb  UR
                  UR                  4$ g Ub;  [        R                  SU5        U R                  R                  X5      nU(       a  X$4$ g )Nget_credentialz'Getting credentials from keyring for %sz$Getting password from keyring for %s)hasattrrH   loggerdebugrL   r   r   get_password)r2   r   r   credr   s        r)   r3   #KeyRingPythonProvider.get_auth_infoQ   s     4<<!122LLBCH<<..s=D}}dmm33LL?E||00?H))r(   r   c                 <    U R                   R                  XU5        g r0   )rH   set_passwordr6   s       r)   r7   $KeyRingPythonProvider.save_auth_infoc   s    !!#:r(   rG   )r.   N)r!   r"   r#   r$   r9   r-   rI   r%   r   r   r3   r7   r'   r    r(   r)   rD   rD   G   sS    AK
  (8BT $;# ; ; ; ;r(   rD   c                       \ rS rSrSrSrS\SS4S jrS\S	\\   S\\	   4S
 jr
S\S	\S\SS4S jrS\S	\S\\   4S jrS\S	\S\SS4S jrSrg)KeyRingCliProviderg   zProvider 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.
Tcmdr.   Nc                     Xl         g r0   rG   )r2   rY   s     r)   rI   KeyRingCliProvider.__init__r   s    r(   r   r   c                 8    Ub  U R                  X5      nUb  X#4$ g r0   )_get_passwordr6   s       r)   r3    KeyRingCliProvider.get_auth_infou   s,     ))#8H#))r(   r   c                 &    U R                  XU5      $ r0   )_set_passwordr6   s       r)   r7   !KeyRingCliProvider.save_auth_info~   s    !!#::r(   service_namec                 |   U R                   c  gU R                   SX/n[        R                  R                  5       nSUS'   [        R
                  " U[        R                  [        R                  US9nUR                  (       a  gUR                  R                  S5      R                  [        R                  5      $ )z;Mirror the implementation of keyring.get_password using cliNgetutf-8PYTHONIOENCODING)stdinstdoutenv)rH   osenvironcopy
subprocessrunDEVNULLPIPE
returncoderh   decodestriplinesep)r2   rb   r   rY   ri   ress         r)   r]    KeyRingCliProvider._get_password   s    <<||UL;jjoo")nn$$??	
 >>zz  )//

;;r(   c                     U R                   c  g[        R                  R                  5       nSUS'   [        R
                  " U R                   SX/U [        R                   3R                  5       USS9  g)z;Mirror the implementation of keyring.set_password using cliNre   rf   setT)inputri   check)rH   rj   rk   rl   rm   rn   rt   encode)r2   rb   r   r   ri   s        r)   r`    KeyRingCliProvider._set_password   sh    <<jjoo")\\5,9Jrzzl+224		
 r(   rG   )r!   r"   r#   r$   r9   r-   r%   rI   r   r   r3   r7   r]   r`   r'   r    r(   r)   rW   rW   g   s     KC D   (8BT ;# ; ; ; ;<# < <# <$#   PT r(   rW   )maxsizeproviderr.   c                 X   [         R                  SU 5        [        (       a  Sn U S;   a"   [        5       n[         R                  S5        U$ U S	;   GaB  [        R                  " S
5      nU(       a  UR                  [        R                  " S5      5      (       a  [        R                   S["        4S j5       n[%        [        R                  " S5      5      n/ nU" 5       R'                  [(        R*                  5       H8  n[%        U5      n	 U	R-                  U5      (       d  UR/                  U5        M8  M:     [(        R*                  R3                  U5      n[        R                  " S
US9nU(       a!  [         R                  SU5        [5        U5      $ [         R                  S5        [7        5       $ ! [         a     GNu[
         aM  nSnU S:X  a  US-   n[         R                  X2[         R                  [        R                  5      S9   S nAGNS nAff = f! [0         a     GM+  f = f)NzKeyring provider requested: %sdisabled)importautozKeyring provider set: importz1Installed copy of keyring fails with exception %sr   z3, trying to find a keyring executable as a fallbackexc_info)rm   r   rH   scriptsr.   c                      [         R                  R                  SS 5      n U c   [         R                  " S5      n U $ U $ ! [        [
        4 a    [         R                  n  U $ f = f)NPATHCS_PATH)rj   rk   rd   confstrAttributeError
ValueErrordefpathpaths    r)   "PATH_as_shutil_which_determines_it@get_keyring_provider.<locals>.PATH_as_shutil_which_determines_it   s_    zz~~fd3<*!zz)4 t +J7 *!zz *s   ?  A#"A#r   z3Keyring provider set: subprocess with executable %szKeyring provider set: disabled)rN   verboseKEYRING_DISABLEDrD   ImportError	ExceptionwarningisEnabledForloggingDEBUGshutilwhich
startswith	sysconfigget_pathtypingno_type_checkr%   r   splitrj   pathsepsamefileappendFileNotFoundErrorjoinrW   r<   )
r~   implexcmsgclir   r   pathsr   ps
             r)   get_keyring_providerr      s   
NN3X> %%	R(*DNN9:K ))ll9%3>>)"4"4Y"?@@!!  " 9--i89GE:<BB2::NJ::g..T* / O ::??5)D,,yt4CNNPRUV%c**
NN34  _  	 	R FC6!QQNN3f.A.A'--.PNQ	RB ) s0    F4 'H4
H	H
AHH
H)(H)c            	          \ rS rSr   S#S\S\\\      S\SS4S jjr\	S\
4S	 j5       r\R                  S
\SS4S j5       r\	S\4S j5       rS\\   S\\   S\\   4S jrS\S\\   4S jrSSS.S\S\S\S\4S jjrS\S\\\\   \\   4   4S jrS\S\4S jrS\S\\\   \\   \4   4S jrS\4S jrS\S\S\4S jrS\S\SS4S  jrS\S\SS4S! jrS"rg)$MultiDomainBasicAuth   TN	prompting
index_urlskeyring_providerr.   c                 D    Xl         X l        X0l        0 U l        S U l        g r0   )r   r   r   	passwords_credentials_to_save)r2   r   r   r   s       r)   rI   MultiDomainBasicAuth.__init__   s&     #$ 0.0 <@!r(   c                 ,    [        U R                  5      $ r0   )r   _keyring_providerr2   s    r)   r   %MultiDomainBasicAuth.keyring_provider   s    #D$:$:;;r(   r~   c                     Xl         g r0   )r   )r2   r~   s     r)   r   r      s
     "*r(   c                 F    U R                   =(       d    U R                  S;  $ )N)r   r   )r   r   r   s    r)   use_keyring MultiDomainBasicAuth.use_keyring   s    
 ~~S!7!7?S!SSr(   r   r   c                 
   U(       d  g U R                   R                  X5      $ ! [         aS  n[        R	                  SSS9  [        R                  S[        U5      5        Sq[        R                  5          SnAgSnAff = f)z3Return the tuple auth for a given url from keyring.Nz&Keyring is skipped due to an exceptionTr   z*Keyring is skipped due to an exception: %s)
r   r3   r   rN   rO   r   r%   r   r   cache_clear)r2   r   r   r   s       r)   _get_keyring_auth&MultiDomainBasicAuth._get_keyring_auth  sv     	((66sEE 	 LLADLQNN<C
  $ ,,.	s   % 
BA	A==Bc                 x  ^ U(       a  U R                   (       d  g[        U5      R                  S5      S-   n[        R                  R                  U5      m/ nU R                    H  nUR                  S5      S-   n[        R                  R                  [        U5      5      nTU:X  a  Us  $ TR                  UR                  :w  a  Me  [        R                  R                  U5      nUR                  U5        M     U(       d  gUR                  SU4S jS9  [        R                  R                  US   5      $ )a  Return 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                 d   > [        TR                  U R                  /5      R                  S5      $ )Nr   )r   r   rfind)	candidate
parsed_urls    r)   <lambda>5MultiDomainBasicAuth._get_index_url.<locals>.<lambda>E  s-    ,OONN#
 eCj#r(   )reversekeyr   )
r   r   rstripurllibparseurlsplitnetlocr   sort
urlunsplit)r2   r   
candidatesindexparsed_indexr   r   s         @r)   _get_index_url#MultiDomainBasicAuth._get_index_url  s    $//"3'..s3c9\\**3/

__ELL%+E!<<001Ee1LML\)  L$7$77--e4Ii( %  	 	
 ||&&z!}55r(   Fallow_netrcallow_keyringoriginal_urlr   r   c                P   [        U5      u  pEnUu  pxUb  Ub  [        R                  SU5        U$ U R                  U5      n	U	(       a-  [        U	5      n
U
(       a  U
u  pn[        R                  SU	5        U	(       a(  WS   b"  Uu  pxUb  Ub  [        R                  SU5        U$ U(       a*  [	        U5      nU(       a  [        R                  SU5        U$ U(       aH  U R                  X5      =(       d    U R                  XW5      nU(       a  [        R                  SU5        U$ Xx4$ )z2Find and return credentials for the specified URL.zFound credentials in url for %szFound index url %sr   z%Found credentials in index url for %sz!Found credentials in netrc for %sz#Found credentials in keyring for %s)r   rN   rO   r   r   r   )r2   r   r   r   r   r   url_user_passwordr   r   	index_url
index_info_index_url_user_password
netrc_authkr_auths                  r)   _get_new_credentials)MultiDomainBasicAuth._get_new_credentialsO  s,    *D*
&&
 /H$8LL:FC$$ '',	3I>J8B5	519= 03?!8H#(<DfM.. '5J@&I!!  &&y; 9&&v8 
 BFK!!r(   c                 0   [        U5      u  p#nU R                  U5      u  pVUb  Uc*  X0R                  ;   a  U R                  U   u  pxUb  XW:X  a  XxpeUc  Ub&  U=(       d    SnU=(       d    SnXV4U R                  U'   Ub  Uc  Uc  Ub
   SU 35       eX%U4$ )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.
 z%Could not load credentials from url: )r   r   r   )	r2   r   r   r   r   r   r   unpws	            r)   _get_url_and_credentials-MultiDomainBasicAuth._get_url_and_credentials  s     4LAQ "66|D  0f6N^^F+FB 8>%'(8#7
  ~2H~2H '/%9DNN6" !h&: X%5		B
 3<.A	B7
 h&&r(   reqc                     U R                  UR                  5      u  p#nX!l        Ub  Ub  [        X45      " U5      nUR                  SU R                  5        U$ )Nresponse)r   r   r   register_hook
handle_401)r2   r   r   r   r   s        r)   __call__MultiDomainBasicAuth.__call__  sW    "&"?"?"Hx H$83C8C 	*doo6
r(   r   c                     U R                   (       a  [        SU S35      OS nU(       d  gU R                  (       a/  U R                  X5      nU(       a  US   b  US   b  US   US   S4$ [	        S5      nX$S4$ )	Nz	User for z: )NNFr      Fz
Password: T)r   r   r   r   r   )r2   r   r   authr   s        r)   _prompt_for_password)MultiDomainBasicAuth._prompt_for_password  s}     9=9y34D$))&;DQ+Q0CAwQ..-4''r(   c                     U R                   (       a,  U R                  (       a  U R                  R                  (       d  g[	        SSS/5      S:H  $ )NFz#Save credentials to keyring [y/N]: yn)r   r   r   r-   r   r   s    r)    _should_save_password_to_keyring5MultiDomainBasicAuth._should_save_password_to_keyring  s;    ##((4483*ELLr(   respkwargsc                    UR                   S:w  a  U$ Su  p4U R                  (       a  U R                  UR                  SSS9u  p4U R                  (       d  U(       d	  U(       d  U$ [
        R                  R                  UR                  5      nSnU(       d%  U(       d  U R                  UR                  5      u  p4nS U l
        UbS  UbP  X44U R                  UR                  '   U(       a/  U R                  5       (       a  [        UR                  UUS9U l
        UR                  nUR                  R!                  5         [#        U=(       d    SU=(       d    S5      " UR$                  5      nUR'                  SU R(                  5        U R                  (       a  UR'                  SU R*                  5        UR,                  R.                  " U40 UD6n	U	R0                  R3                  U5        U	$ )	N  )NNFTr   )r   r   r   r   r   )status_coder   r   r   r   r   r   urlparser   r   r   r   r   r   contentrawrelease_connr   requestr   warn_on_401save_credentials
connectionsendhistoryr   )
r2   r   r   r   r   parsedsaver   r   new_resps
             r)   r   MultiDomainBasicAuth.handle_401  s    s"K' !%!:!:!" "; "H ~~hxK&&txx0 '+'@'@'O$H %)!H$8-5,@DNN6==) ==??,7%%-) LL HNHN;DLLI*d&6&67
 $$j$*?*?@ ??''6v6%r(   c                 z    UR                   S:X  a+  [        R                  SUR                  R                  5        gg)z6Response callback to warn about incorrect credentials.r  z)401 Error, Credentials not correct for %sN)r  rN   r   r  r   )r2   r   r   s      r)   r   MultiDomainBasicAuth.warn_on_401  s1    s"NN;   #r(   c                    U R                   R                  (       d   S5       eU R                  nSU l        U(       ac  UR                  S:  aR   [        R                  S5        U R                   R                  UR                  UR                  UR                  5        ggg! [         a    [        R                  S5         gf = f)z1Response callback to save credentials on success.z'should never reach here without keyringNi  zSaving credentials to keyringzFailed to save credentials)r   r-   r   r  rN   infor7   r   r   r   r   	exception)r2   r   r   credss       r)   r	  %MultiDomainBasicAuth.save_credentials'  s     !!--	54	5- ))$(!T%%+?;<%%44IIu~~u~~ ,5  ?  !=>?s   AB! !CC)r   r   r   r   r   r   )TNr   )r!   r"   r#   r$   r:   r   r
   r%   rI   propertyr+   r   setterr   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r'   r    r(   r)   r   r      s    *. &	@@ T#Y'@ 	@
 
@" <"5 < < * * * * TT T Tc] 3- 
(		4.6# .6(3- .6h !#7"7" 	7"
 7" 
7"r.'.'	sHSM8C=0	1.'`G  "((	x}hsmT1	2(M$ M=x =3 =8 =~ C D ?X ? ? ?r(   r   )5r9   r   rj   r   rm   r   r   urllib.parser   abcr   r   	functoolsr   os.pathr   pathlibr   r   r	   r
   r   r   r   pip._vendor.requests.authr   r   pip._vendor.requests.modelsr   r   pip._vendor.requests.utilsr   pip._internal.utils.loggingr   pip._internal.utils.miscr   r   r   r   r    pip._internal.vcs.versioncontrolr   r!   rN   r   r   r+   r<   rD   rW   r%   r   r   r    r(   r)   <module>r%     s     	      #     ? ? = 9 5 1  6	8	 * R# R	- 	;/ ;@8, 8v 4:!3 :!+> :! :!zV?8 V?r(   