File: //var/opt/nydus/ops/mysql/connector/aio/plugins/__pycache__/mysql_native_password.cpython-39.pyc
a
�,�h� � @ sx d Z ddlZddlmZ ddlmZmZmZ ddlm Z ddl
mZ ddlm
Z
er`d d
lmZ dZG dd� de
�ZdS )
z&Native Password Authentication Plugin.� N)�sha1)�
TYPE_CHECKING�Any�Optional)�InterfaceError)�logger� )�MySQLAuthPlugin� )�MySQLSocket�MySQLNativePasswordAuthPluginc @ sn e Zd ZdZeed�dd�Zeed�dd��Zee d�dd ��Z
eeee d
�dd�Z
d
eeed�dd�ZdS )r zBClass implementing the MySQL Native Password authentication plugin)� auth_data�returnc
C s� |st d��| jsdS d}zXt| j�� ��� }t|��� }t|| ��� }dd� t||�D �}tjdg|�R � }W n: tjt fy� } zt d|� ��|�W Y d}~n
d}~0 0 |S )z;Prepares and returns password as native MySQL 4.1+ passwordz"Missing authentication data (seed)� Nc S s g | ]\}}||A �qS � r )�.0�h1�h3r r �d/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/connector/aio/plugins/mysql_native_password.py�
<listcomp>? r zCMySQLNativePasswordAuthPlugin._prepare_password.<locals>.<listcomp>Z20BzFailed scrambling password; )
r Z _passwordr �encode�digest�zip�struct�pack�error� TypeError)�selfr
Zhash4Zhash1Zhash2Zhash3Zxored�errr r r �_prepare_password2 s &z/MySQLNativePasswordAuthPlugin._prepare_password)r c C s dS )zPlugin official name.Zmysql_native_passwordr �r r r r �nameF s z"MySQLNativePasswordAuthPlugin.namec C s dS )z'Signals whether or not SSL is required.Fr r r r r �requires_sslK s z*MySQLNativePasswordAuthPlugin.requires_ssl)r
�kwargsr c K s
| � |�S )a� Make the client's authorization response.
Args:
auth_data: Authorization data.
kwargs: Custom configuration to be passed to the auth plugin
when invoked. The parameters defined here will override the ones
defined in the auth plugin itself.
Returns:
packet: Client's authorization response.
)r )r r
r# r r r �
auth_responseP s z+MySQLNativePasswordAuthPlugin.auth_responser )�sockr
r# r c � sf | j |fi |��}|du r"td��t�d|t|�� |�|�I dH t|�� I dH �}t�d|� |S )aS Handles server's `auth switch request` response.
Args:
sock: Pointer to the socket connection.
auth_data: Plugin provided data (extracted from a packet
representing an `auth switch request` response).
kwargs: Custom configuration to be passed to the auth plugin
when invoked. The parameters defined here will override the ones
defined in the auth plugin itself.
Returns:
packet: Last server's response after back-and-forth
communication.
NzGot a NULL auth responsez# request: %s size: %sz# server response packet: %s)r$ r r �debug�len�write�bytes�read)r r% r
r# �responseZpktr r r �auth_switch_response^ s z2MySQLNativePasswordAuthPlugin.auth_switch_responseN)�__name__�
__module__�__qualname__�__doc__r) r �property�strr! �boolr"