File: //var/opt/nydus/ops/mysql/connector/aio/__pycache__/protocol.cpython-39.pyc
a
�,�h51 � @ s� d Z dgZddlZddlmZmZmZmZmZ ddl m
Z
mZ ddlm
Z
mZmZ ddlmZ dd lmZmZmZ dd
lmZmZmZmZ ddlmZmZ dd
lmZ ddl m!Z!m"Z" ddl#m$Z$ G dd� de�ZdS )z,Implements the MySQL Client/Server protocol.�
MySQLProtocol� N)�Any�Dict�List�Optional�Tuple� )�
ClientFlag� ServerCmd)�InterfaceError�ProgrammingError�
get_exception)�logger)�DEFAULT_CHARSET_ID�DEFAULT_MAX_ALLOWED_PACKETr )�BinaryProtocolType�DescriptionType�
EofPacketType�
HandShakeType)� int1store�read_lc_string_list� )�MySQLSocket)�MySQLAuthPlugin�get_auth_plugin)�"MySQLCachingSHA2PasswordAuthPluginc @ s( e Zd ZdZedeeeeeee e ee
eef eee
f d� dd��Zedededdddddf
eeeee eeeee ee ee
eef e e ee
eef eee
f d�d d
��Zdeee eeeeeed
f ee f d�dd�Zdeeed
f eeeeee d
f ee f d�dd�ZdS )r zSImplements MySQL client/server protocol.
Create and parses MySQL packets.
NF) � auth_data�username�password�client_flags�auth_plugin�auth_plugin_class�ssl_enabled�
plugin_config�returnc
C s� |sdt |||d�fS |du r"i }z*t||�|||d�}|j| fi |��} W n8 ttfy� }
ztd|
� ��|
�W Y d}
~
n
d}
~
0 0 | du r�td|j� ���|tj@ r�tt | ��| n| d } | |fS )a Prepare the first authentication response.
Args:
auth_data: Authorization data from initial handshake.
username: Account's username.
password: Account's password.
client_flags: Integer representing client capabilities flags.
auth_plugin: Authorization plugin name.
auth_plugin_class: Authorization plugin class (has higher precedence
than the authorization plugin name).
ssl_enabled: Whether SSL is enabled or not.
plugin_config: 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:
auth_response: Authorization plugin response.
auth_strategy: Authorization plugin instance created based
on the provided `auth_plugin` and `auth_plugin_class`
parameters.
Raises:
InterfaceError: If authentication fails or when got a NULL auth response.
� )r"