HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/paramiko/__pycache__/auth_strategy.cpython-310.pyc
o

�h�,�@s�dZddlmZddlmZddlmZddlmZGdd�d�Z	Gd	d
�d
e	�Z
Gdd�de	�ZGd
d�de	�ZGdd�de�Z
Gdd�de�Zedddg�ZGdd�de�ZGdd�de�ZGdd�d�ZdS)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)�
get_logger)�AuthenticationExceptionc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
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.
    cC�
||_dS�N��username)�selfr�r
�I/usr/local/CyberCP/lib/python3.10/site-packages/paramiko/auth_strategy.py�__init__�
zAuthSource.__init__cKs0dd�|��D�}d�|�}|jj�d|�d�S)NcSsg|]\}}|�d|���qS)�=r
)�.0�k�vr
r
r�
<listcomp>sz$AuthSource._repr.<locals>.<listcomp>z, �(�))�items�join�	__class__�__name__)r�kwargs�pairs�joinedr
r
r�_reprs
zAuthSource._reprcCs|��Sr	)r�rr
r
r�__repr__"szAuthSource.__repr__cC�t�)z)
        Perform authentication.
        ��NotImplementedError�r�	transportr
r
r�authenticate%szAuthSource.authenticateN)r�
__module__�__qualname__�__doc__rrr!r'r
r
r
rrsrc@�eZdZdZdd�ZdS)�NoneAuthzS
    Auth type "none", ie https://www.rfc-editor.org/rfc/rfc4252#section-5.2 .
    cCs|�|j�Sr	)�	auth_nonerr%r
r
rr'1szNoneAuth.authenticateN�rr(r)r*r'r
r
r
rr,,sr,cs4eZdZdZ�fdd�Z�fdd�Zdd�Z�ZS)�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�t�j|d�||_dS�Nr
)�superr�password_getter)rrr3�rr
rrDs
zPassword.__init__cst�j|jd�S)N)�user)r2rrr r4r
rr!HszPassword.__repr__cCs|��}|�|j|�Sr	)r3�
auth_passwordr)rr&�passwordr
r
rr'MszPassword.authenticate)rr(r)r*rr!r'�
__classcell__r
r
r4rr/5s
r/c@r+)�
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.
    cCs|�|j|j�Sr	)�auth_publickeyr�pkeyr%r
r
rr'eszPrivateKey.authenticateNr.r
r
r
rr9Xsr9cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�InMemoryPrivateKeyz1
    An in-memory, decrypted `.PKey` object.
    cr0r1)r2rr;)rrr;r4r
rrns
zInMemoryPrivateKey.__init__cs(t�j|jd�}t|jt�r|d7}|S)N)r;z [agent])r2rr;�
isinstancer)r�repr4r
rr!sszInMemoryPrivateKey.__repr__�rr(r)r*rr!r8r
r
r4rr<isr<c�(eZdZdZ�fdd�Zdd�Z�ZS)�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.
    cs>t�j|d�||_d}||vrtd|����||_||_dS)Nr
)z
ssh-configz
python-configz
implicit-homez source argument must be one of: )r2r�source�
ValueError�pathr;)rrrBrDr;�allowedr4r
rr�s
zOnDiskPrivateKey.__init__cCs|j|j|jt|j�d�S)N)�keyrBrD)rr;rB�strrDr r
r
rr!�s�zOnDiskPrivateKey.__repr__r?r
r
r4rrA|s
rA�SourceResultrB�resultcr@)�
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.
    cs||_t�j|i|��dSr	)�strategyr2r)rrK�argsrr4r
rr�szAuthResult.__init__cCsd�dd�|D��S)N�
css&�|]}|j�d|jpd��VqdS)z -> �successN)rBrI)r�xr
r
r�	<genexpr>�s�
�z%AuthResult.__str__.<locals>.<genexpr>)rr r
r
r�__str__�s
�zAuthResult.__str__)rr(r)r*rrQr8r
r
r4rrJ�srJc@s eZdZdZdd�Zdd�ZdS)�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.
    cCrr	�rI)rrIr
r
rr�rzAuthFailure.__init__cCsdt|j�S)NrM)rGrIr r
r
rrQ�szAuthFailure.__str__N)rr(r)r*rrQr
r
r
rrR�s
rRc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�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.
    cCs||_tt�|_dSr	)�
ssh_configrr�log)rrUr
r
rr�szAuthStrategy.__init__cCr")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 r
r
r�get_sources�s
zAuthStrategy.get_sourcescCs�d}t|d�}|��D]E}|j�d|���z	|�|�}d}Wn$tyC}z|}|jj}|j�d|�d|���WYd}~nd}~ww|�	t
||��|rPnq|sXt|d��|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)rKzTrying TzAuthentication via z
 failed with NrS)rJrWrV�debugr'�	Exceptionrr�info�appendrHrR)rr&�	succeeded�overall_resultrBrI�e�source_classr
r
rr's,

����
zAuthStrategy.authenticateN)rr(r)r*rrWr'r
r
r
rrT�s
rTN)r*�collectionsr�agentr�utilr�
ssh_exceptionrrr,r/r9r<rArH�listrJrRrTr
r
r
r�<module>s	#!.