§
    3xÅjã,  ã                   óN  — d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d„ d¦  «        Z	 G d	„ d
e	¦  «        Z
 G d„ de	¦  «        Z G d„ de	¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z edddg¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ d¦  «        ZdS )z¿
Modern, adaptable authentication machinery.

Replaces certain parts of `.SSHClient`. For a concrete implementation, see the
``OpenSSHAuthStrategy`` class in `Fabric <https://fabfile.org>`_.
é    )Ú
namedtupleé   )ÚAgentKey)ÚAuthenticationException)Ú
get_loggerc                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )Ú
AuthSourcezã
    Some SSH authentication source, such as a password, private key, or agent.

    See subclasses in this module for concrete implementations.

    All implementations must accept at least a ``username`` (``str``) kwarg.
    c                 ó   — || _         d S ©N©Úusername)Úselfr   s     úGC:\Projects\Historical\venv\Lib\site-packages\paramiko/auth_strategy.pyÚ__init__zAuthSource.__init__   s   € Ø ˆŒˆˆó    c                 óŒ   — d„ |                      ¦   «         D ¦   «         }d                     |¦  «        }| j        j        › d|› d�S )Nc                 ó"   — g | ]\  }}|› d |›�‘ŒS )ú=© )Ú.0ÚkÚvs      r   ú
<listcomp>z$AuthSource._repr.<locals>.<listcomp>   s&   € Ð9Ð9Ð9¡$ ! Q�A��˜��Ð9Ð9Ð9r   z, ú(ú))ÚitemsÚjoinÚ	__class__Ú__name__)r   ÚkwargsÚpairsÚjoineds       r   Ú_reprzAuthSource._repr   sL   € ð :Ð9¨&¯,ª,©.¬.Ð9Ñ9Ô9ˆØ—’˜5Ñ!Ô!ˆØ”.Ô)Ð5Ð5¨FÐ5Ð5Ð5Ð5r   c                 ó*   — |                       ¦   «         S r   )r#   ©r   s    r   Ú__repr__zAuthSource.__repr__"   s   € Ø�zŠz‰|Œ|Ðr   c                 ó   — t           ‚)z)
        Perform authentication.
        ©ÚNotImplementedError©r   Ú	transports     r   ÚauthenticatezAuthSource.authenticate%   s
   € õ "Ð!r   N)r   Ú
__module__Ú__qualname__Ú__doc__r   r#   r&   r,   r   r   r   r	   r	      sZ   € € € € € ðð ð!ð !ð !ð6ð 6ð 6ðð ð ð"ð "ð "ð "ð "r   r	   c                   ó   — e Zd ZdZd„ ZdS )ÚNoneAuthzS
    Auth type "none", ie https://www.rfc-editor.org/rfc/rfc4252#section-5.2 .
    c                 ó6   — |                      | j        ¦  «        S r   )Ú	auth_noner   r*   s     r   r,   zNoneAuth.authenticate1   s   € Ø×"Ò" 4¤=Ñ1Ô1Ð1r   N©r   r-   r.   r/   r,   r   r   r   r1   r1   ,   s-   € € € € € ðð ð2ð 2ð 2ð 2ð 2r   r1   c                   ó2   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zd„ Zˆ xZS )ÚPassworda  
    Password authentication.

    :param callable password_getter:
        A lazy callable that should return a `str` password value at
        authentication time, such as a `functools.partial` wrapping
        `getpass.getpass`, an API call to a secrets store, or similar.

        If you already know the password at instantiation time, you should
        simply use something like ``lambda: "my literal"`` (for a literal, but
        also, shame on you!) or ``lambda: variable_name`` (for something stored
        in a variable).
    c                 óZ   •— t          ¦   «                              |¬¦  «         || _        d S ©Nr   )Úsuperr   Úpassword_getter)r   r   r:   r   s      €r   r   zPassword.__init__D   s,   ø€ Ý‰Œ×Ò (ÐÑ+Ô+Ð+Ø.ˆÔÐÐr   c                 óR   •— t          ¦   «                              | j        ¬¦  «        S )N)Úuser)r9   r#   r   )r   r   s    €r   r&   zPassword.__repr__H   s   ø€ õ ‰wŒw�}Š} $¤-ˆ}Ñ0Ô0Ð0r   c                 ó`   — |                       ¦   «         }|                     | j        |¦  «        S r   )r:   Úauth_passwordr   )r   r+   Úpasswords      r   r,   zPassword.authenticateM   s-   € ð ×'Ò'Ñ)Ô)ˆØ×&Ò& t¤}°hÑ?Ô?Ð?r   )r   r-   r.   r/   r   r&   r,   Ú__classcell__©r   s   @r   r6   r6   5   sq   ø€ € € € € ðð ð/ð /ð /ð /ð /ð1ð 1ð 1ð 1ð 1ð
@ð @ð @ð @ð @ð @ð @r   r6   c                   ó   — e Zd ZdZd„ ZdS )Ú
PrivateKeya‹  
    Essentially a mixin for private keys.

    Knows how to auth, but leaves key material discovery/loading/decryption to
    subclasses.

    Subclasses **must** ensure that they've set ``self.pkey`` to a decrypted
    `.PKey` instance before calling ``super().authenticate``; typically
    either in their ``__init__``, or in an overridden ``authenticate`` prior to
    its `super` call.
    c                 óB   — |                      | j        | j        ¦  «        S r   )Úauth_publickeyr   Úpkeyr*   s     r   r,   zPrivateKey.authenticatef   s   € Ø×'Ò'¨¬°t´yÑAÔAÐAr   Nr4   r   r   r   rC   rC   Y   s2   € € € € € ð
ð 
ðBð Bð Bð Bð Br   rC   c                   ó,   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zˆ xZS )ÚInMemoryPrivateKeyz1
    An in-memory, decrypted `.PKey` object.
    c                 óZ   •— t          ¦   «                              |¬¦  «         || _        d S r8   )r9   r   rF   )r   r   rF   r   s      €r   r   zInMemoryPrivateKey.__init__o   s)   ø€ Ý‰Œ×Ò (ÐÑ+Ô+Ð+àˆŒ	ˆ	ˆ	r   c                 ó”   •— t          ¦   «                              | j        ¬¦  «        }t          | j        t          ¦  «        r|dz  }|S )N)rF   z [agent])r9   r#   rF   Ú
isinstancer   )r   Úrepr   s     €r   r&   zInMemoryPrivateKey.__repr__t   sA   ø€ õ ‰gŒg�mŠm ¤ˆmÑ+Ô+ˆÝ�d”i¥Ñ*Ô*ð 	Ø�:ÑˆCØˆ
r   ©r   r-   r.   r/   r   r&   r@   rA   s   @r   rH   rH   j   s[   ø€ € € € € ðð ðð ð ð ð ð
ð ð ð ð ð ð ð ð r   rH   c                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )ÚOnDiskPrivateKeya™  
    Some on-disk private key that needs opening and possibly decrypting.

    :param str source:
        String tracking where this key's path was specified; should be one of
        ``"ssh-config"``, ``"python-config"``, or ``"implicit-home"``.
    :param Path path:
        The filesystem path this key was loaded from.
    :param PKey pkey:
        The `PKey` object this auth source uses/represents.
    c                 ó¦   •— t          ¦   «                              |¬¦  «         || _        d}||vrt          d|›�¦  «        ‚|| _        || _        d S )Nr   )z
ssh-configzpython-configzimplicit-homez source argument must be one of: )r9   r   ÚsourceÚ
ValueErrorÚpathrF   )r   r   rQ   rS   rF   Úallowedr   s         €r   r   zOnDiskPrivateKey.__init__Š   s^   ø€ Ý‰Œ×Ò (ÐÑ+Ô+Ð+ØˆŒØBˆØ˜Ð Ð ÝÐKÀÐKÐKÑLÔLÐLØˆŒ	àˆŒ	ˆ	ˆ	r   c                 ój   — |                       | j        | j        t          | j        ¦  «        ¬¦  «        S )N)ÚkeyrQ   rS   )r#   rF   rQ   ÚstrrS   r%   s    r   r&   zOnDiskPrivateKey.__repr__”   s0   € Ø�zŠzØ”	 $¤+µC¸¼	±N´Nð ñ 
ô 
ð 	
r   rM   rA   s   @r   rO   rO   }   sQ   ø€ € € € € ð
ð 
ðð ð ð ð ð
ð 
ð 
ð 
ð 
ð 
ð 
r   rO   ÚSourceResultrQ   Úresultc                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )Ú
AuthResultaÞ  
    Represents a partial or complete SSH authentication attempt.

    This class conceptually extends `AuthStrategy` by pairing the former's
    authentication **sources** with the **results** of trying to authenticate
    with them.

    `AuthResult` is a (subclass of) `list` of `namedtuple`, which are of the
    form ``namedtuple('SourceResult', 'source', 'result')`` (where the
    ``source`` member is an `AuthSource` and the ``result`` member is either a
    return value from the relevant `.Transport` method, or an exception
    object).

    .. note::
        Transport auth method results are always themselves a ``list`` of "next
        allowable authentication methods".

        In the simple case of "you just authenticated successfully", it's an
        empty list; if your auth was rejected but you're allowed to try again,
        it will be a list of string method names like ``pubkey`` or
        ``password``.

        The ``__str__`` of this class represents the empty-list scenario as the
        word ``success``, which should make reading the result of an
        authentication session more obvious to humans.

    Instances also have a `strategy` attribute referencing the `AuthStrategy`
    which was attempted.
    c                 óH   •— || _          t          ¦   «         j        |i |¤Ž d S r   )Ústrategyr9   r   )r   r]   Úargsr    r   s       €r   r   zAuthResult.__init__É   s,   ø€ Ø ˆŒØ�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ð)Ð)r   c                 ó@   — d                      d„ | D ¦   «         ¦  «        S )Nú
c              3   ó<   K  — | ]}|j         › d |j        pd› �V — ŒdS )z -> ÚsuccessN)rQ   rY   )r   Úxs     r   ú	<genexpr>z%AuthResult.__str__.<locals>.<genexpr>Ò   sJ   è è € ð 
ð 
Ø9:ˆqŒxÐ4Ð4˜QœXÐ2¨Ð4Ð4ð
ð 
ð 
ð 
ð 
ð 
r   )r   r%   s    r   Ú__str__zAuthResult.__str__Í   s6   € ð
 �yŠyð 
ð 
Ø>Bð
ñ 
ô 
ñ 
ô 
ð 	
r   )r   r-   r.   r/   r   re   r@   rA   s   @r   r[   r[   ª   sQ   ø€ € € € € ðð ð<*ð *ð *ð *ð *ð
ð 
ð 
ð 
ð 
ð 
ð 
r   r[   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚAuthFailurea®  
    Basic exception wrapping an `AuthResult` indicating overall auth failure.

    Note that `AuthFailure` descends from `AuthenticationException` but is
    generally "higher level"; the latter is now only raised by individual
    `AuthSource` attempts and should typically only be seen by users when
    encapsulated in this class. It subclasses `AuthenticationException`
    primarily for backwards compatibility reasons.
    c                 ó   — || _         d S r   ©rY   )r   rY   s     r   r   zAuthFailure.__init__ã   s   € ØˆŒˆˆr   c                 ó0   — dt          | j        ¦  «        z   S )Nr`   )rW   rY   r%   s    r   re   zAuthFailure.__str__æ   s   € Ø•c˜$œ+Ñ&Ô&Ñ&Ð&r   N)r   r-   r.   r/   r   re   r   r   r   rg   rg   Ø   s<   € € € € € ðð ðð ð ð'ð 'ð 'ð 'ð 'r   rg   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚAuthStrategya   
    This class represents one or more attempts to auth with an SSH server.

    By default, subclasses must at least accept an ``ssh_config``
    (`.SSHConfig`) keyword argument, but may opt to accept more as needed for
    their particular strategy.
    c                 óF   — || _         t          t          ¦  «        | _        d S r   )Ú
ssh_configr   r   Úlog)r   rn   s     r   r   zAuthStrategy.__init__ó   s   € ð %ˆŒÝ�hÑ'Ô'ˆŒˆˆr   c                 ó   — t           ‚)a[  
        Generator yielding `AuthSource` instances, in the order to try.

        This is the primary override point for subclasses: you figure out what
        sources you need, and ``yield`` them.

        Subclasses _of_ subclasses may find themselves wanting to do things
        like filtering or discarding around a call to `super`.
        r(   r%   s    r   Úget_sourceszAuthStrategy.get_sourcesú   s
   € õ "Ð!r   c                 óÀ  — d}t          | ¬¦  «        }|                      ¦   «         D ]¤}| j                             d|› �¦  «         	 |                     |¦  «        }d}nE# t
          $ r8}|}|j        j        }| j                             d|› d|› �¦  «         Y d}~nd}~ww xY w| 	                    t          ||¦  «        ¦  «         |r nŒ¥|st          |¬¦  «        ‚|S )	z»
        Handles attempting `AuthSource` instances yielded from `get_sources`.

        You *normally* won't need to override this, but it's an option for
        advanced users.
        F)r]   zTrying TzAuthentication via z failed with Nri   )r[   rq   ro   Údebugr,   Ú	Exceptionr   r   ÚinfoÚappendrX   rg   )r   r+   Ú	succeededÚoverall_resultrQ   rY   ÚeÚsource_classs           r   r,   zAuthStrategy.authenticate  s;  € ð ˆ	Ý#¨TÐ2Ñ2Ô2ˆð ×&Ò&Ñ(Ô(ð 	ð 	ˆFØŒH�NŠNÐ- VÐ-Ð-Ñ.Ô.Ð.ðØ×,Ò,¨YÑ7Ô7�Ø �	�	øõ
 ð ð ð Ø�ð  !œ{Ô3�Ø”—’ØM¨&ÐMÐM¸|ÐMÐMñô ð ð ð ð ð ð øøøøðøøøð ×!Ò!¥,¨v°vÑ">Ô">Ñ?Ô?Ð?Øð Ø�ðð ð 	5Ý ^Ð4Ñ4Ô4Ð4àÐs   ÁAÁ
B!Á).BÂB!N)r   r-   r.   r/   r   rq   r,   r   r   r   rl   rl   ê   sK   € € € € € ðð ð(ð (ð (ð
"ð 
"ð 
"ð+ð +ð +ð +ð +r   rl   N)r/   Úcollectionsr   Úagentr   Ússh_exceptionr   Úutilr   r	   r1   r6   rC   rH   rO   rX   Úlistr[   rg   rl   r   r   r   ú<module>r€      s  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø Ð Ð Ð Ð Ð ð"ð "ð "ð "ð "ñ "ô "ð "ð:2ð 2ð 2ð 2ð 2ˆzñ 2ô 2ð 2ð@ð @ð @ð @ð @ˆzñ @ô @ð @ðHBð Bð Bð Bð B�ñ Bô Bð Bð"ð ð ð ð ˜ñ ô ð ð&
ð 
ð 
ð 
ð 
�zñ 
ô 
ð 
ðB ˆz˜.¨8°XÐ*>Ñ?Ô?€ð*
ð *
ð *
ð *
ð *
�ñ *
ô *
ð *
ð\'ð 'ð 'ð 'ð 'Ð)ñ 'ô 'ð 'ð$Gð Gð Gð Gð Gñ Gô Gð Gð Gð Gr   