%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/passlib/handlers/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/passlib/handlers/__pycache__/misc.cpython-39.opt-1.pyc

a

f�Wc}'�@s�dZddlZddlZe�e�ZddlmZddlm	Z	m
Z
ddlmZm
Z
mZddlmmZgd�ZGdd�dejjej�Ze
d	�Zd
ZGdd�dejjej�ZGd
d�dej�ZdS)z.passlib.handlers.misc - misc generic handlers
�N)�warn)�
to_native_str�str_consteq)�unicode�u�unicode_or_bytes_types)�
unix_disabled�
unix_fallback�	plaintextcsLeZdZdZdZdZedd��Zd�fdd�	Zdd	�Z	ed
d
d��Z
�ZS)r	a�This class provides the fallback behavior for unix shadow files, and follows the :ref:`password-hash-api`.

    This class does not implement a hash, but instead provides fallback
    behavior as found in /etc/shadow on most unix variants.
    If used, should be the last scheme in the context.

    * this class will positively identify all hash strings.
    * for security, passwords will always hash to ``!``.
    * it rejects all passwords if the hash is NOT an empty string (``!`` or ``*`` are frequently used).
    * by default it rejects all passwords if the hash is an empty string,
      but if ``enable_wildcard=True`` is passed to verify(),
      all passwords will be allowed through if the hash is an empty string.

    .. deprecated:: 1.6
        This has been deprecated due to its "wildcard" feature,
        and will be removed in Passlib 1.8. Use :class:`unix_disabled` instead.
    )�enable_wildcardcCs t|t�rdStj�|d��dS�NT�hash��
isinstancer�uh�exc�ExpectedStringError��clsr
�r�9/usr/lib/python3.9/site-packages/passlib/handlers/misc.py�identify.s
zunix_fallback.identifyFcs*tdt�tt|�jfi|��||_dS)Nzf'unix_fallback' is deprecated, and will be removed in Passlib 1.8; please use 'unix_disabled' instead.)r�DeprecationWarning�superr	�__init__r)�selfr�kwds��	__class__rrr5s
�zunix_fallback.__init__cCs|jr|jStd�SdS)N�!)Zchecksumr)r�secretrrr�_calc_checksum=szunix_fallback._calc_checksumcCs4t�|�t|t�s$tj�|d��n|r,dS|SdS)Nr
F)r�validate_secretrrrr)rr r
rrrr�verifyEs

zunix_fallback.verify)F)F)�__name__�
__module__�__qualname__�__doc__�name�context_kwds�classmethodrrr!r#�
__classcell__rrrrr	s
r	z*!s*!cs�eZdZdZdZdZdZeee	��Z
dejvr8e
d�Zne
d�Zed�fdd	�	�Zed
d��Zedd
��Zedd��Zejddd�eddd���Zeddd��Zedd��Z�ZS)raThis class provides disabled password behavior for unix shadow files,
    and follows the :ref:`password-hash-api`.

    This class does not implement a hash, but instead matches the "disabled account"
    strings found in ``/etc/shadow`` on most Unix variants. "encrypting" a password
    will simply return the disabled account marker. It will reject all passwords,
    no matter the hash string. The :meth:`~passlib.ifc.PasswordHash.hash`
    method supports one optional keyword:

    :type marker: str
    :param marker:
        Optional marker string which overrides the platform default
        used to indicate a disabled account.

        If not specified, this will default to ``"*"`` on BSD systems,
        and use the Linux default ``"!"`` for all other platforms.
        (:attr:`!unix_disabled.default_marker` will contain the default value)

    .. versionadded:: 1.6
        This class was added as a replacement for the now-deprecated
        :class:`unix_fallback` class, which had some undesirable features.
    ��markerrZbsd�*rNcs>tt|�jfi|��}|dur:|�|�s4td|��||_|S)Nzinvalid marker: %r)rr�usingr�
ValueError�default_marker)rr-r�subclsrrrr/xs
zunix_disabled.usingcCs@t|t�rt}nt|t�r t}ntj�|d��|p>|d|vS)Nr
r)rr�
_MARKER_CHARS�bytes�
_MARKER_BYTESrrr)rr
�startrrrr�s

zunix_disabled.identifycCs$t�|�|�|�s tj�|��dS)NF)rr"rr�InvalidHashError)rr r
rrrr#�s

zunix_disabled.verifycKsB|r&t�||�|jfi|���|�St�|�|j}t|dd�S)Nr-�Zparam)rZwarn_hash_settings_deprecationr/r
r"r1r)rr rr-rrrr
�s
zunix_disabled.hash�1.7�2.0�Z
deprecatedZremovedcCsT|�|�stj�|��n8|r2t�|�t|dd�S|durF|j|d�}|�|�SdS)N�configr8r,)rrrr7r"rr/r
)rr r<r-rrr�genhash�s

zunix_disabled.genhashcCsB|�d�}|dur>t|dd�}|�|�r2|�|�}|r>||7}|S)N�r
r8)r
rr�enable)rr
�outrrr�disable�s


zunix_disabled.disablecCsVt|dd�}|jD]2}|�|�r|t|�d�}|r<|Std��qtj�|��dS)Nr
r8zcannot restore original hash)r�_disable_prefixes�
startswith�lenr0rrr7)rr
�prefixZorigrrrr?�s


zunix_disabled.enable)N)N)N)r$r%r&r'r(�setting_kwdsr)�tuple�strr3rB�sys�platformrr1r*r/rr#r
r�deprecated_methodr=rAr?r+rrrrrRs.




	rc@s~eZdZdZdZdZdZdZedd��Z	eddd	��Z
edd
d��Zej
dd
d�edd���Zej
dd
d�eddd���ZdS)r
a~This class stores passwords in plaintext, and follows the :ref:`password-hash-api`.

    The :meth:`~passlib.ifc.PasswordHash.hash`, :meth:`~passlib.ifc.PasswordHash.genhash`, and :meth:`~passlib.ifc.PasswordHash.verify` methods all require the
    following additional contextual keyword:

    :type encoding: str
    :param encoding:
        This controls the character encoding to use (defaults to ``utf-8``).

        This encoding will be used to encode :class:`!unicode` passwords
        under Python 2, and decode :class:`!bytes` hashes under Python 3.

    .. versionchanged:: 1.6
        The ``encoding`` keyword was added.
    r��encodingzutf-8cCs t|t�rdStj�|d��dSrrrrrrr�s
zplaintext.identifyNcCs t�|�|s|j}t||d�S)Nr )rr"�default_encodingr)rr rMrrrr
�s
zplaintext.hashcCs>|s
|j}t||d�}|�|�s,tj�|��t|�||�|�S)Nr
)rNrrrrr7rr
)rr r
rMrrrr#�s
zplaintext.verifyr9r:r;cCs
|�d�S)Nr>)r
)rrrr�	genconfig�szplaintext.genconfigcCs$|�|�stj�|��|j||d�S)NrL)rrrr7r
)rr r<rMrrrr=s
zplaintext.genhash)N)N)N)r$r%r&r'r(rFr)rNr*rr
r#rrKrOr=rrrrr
�s"
r
)r'rIZloggingZ	getLoggerr$�log�warningsrZ
passlib.utilsrrZpasslib.utils.compatrrrZpasslib.utils.handlersZutils�handlersr�__all__ZifcZDisabledHashZ
StaticHandlerr	r3r5ZMinimalHandlerrr
rrrr�<module>s	6~

Zerion Mini Shell 1.0