OwlCyberSecurity - MANAGER
Edit File: authentication.cpython-312.pyc
� U��gO � � � d Z ddlmZ ddlZddlmZ ddlmZmZ G d� de � Z G d � d e � Z G d� de � Z G d � de � Z d� Zy)z5Implementing support for MySQL Authentication Plugins� )�sha1N� )�errors)�PY2�isstrc �0 � e Zd ZdZdZdZ dd�Zd� Zd� Zy) �BaseAuthPlugina� Base class for authentication plugins Classes inheriting from BaseAuthPlugin should implement the method prepare_password(). When instantiating, auth_data argument is required. The username, password and database are optional. The ssl_enabled argument can be used to tell the plugin whether SSL is active or not. The method auth_response() method is used to retrieve the password which was prepared by prepare_password(). F� Nc �J � || _ || _ || _ || _ || _ y)�InitializationN)� _auth_data� _username� _password� _database�_ssl_enabled)�self� auth_data�username�password�database�ssl_enableds �u/opt/hc_python/lib64/python3.12/site-packages/../../../lib/python3.12/site-packages/mysql/connector/authentication.py�__init__zBaseAuthPlugin.__init__2 s( � � $���!���!���!���'��� c � � t �)z�Prepares and returns password to be send to MySQL This method needs to be implemented by classes inheriting from this class. It is used by the auth_response() method. Raises NotImplementedError. )�NotImplementedError�r s r �prepare_passwordzBaseAuthPlugin.prepare_password; s � � "�!r c � � | j r;| j s/t j dj | j �� � �| j � S )z�Returns the prepared password to send to MySQL Raises InterfaceError on errors. For example, when SSL is required by not enabled. Returns str z{name} requires SSL)�name)�requires_sslr r �InterfaceError�format�plugin_namer r s r � auth_responsezBaseAuthPlugin.auth_responseE sT � � ���T�%6�%6��'�'�(=�(D�(D��%�%� )E� )'� (� (��$�$�&�&r )NNNF) �__name__� __module__�__qualname__�__doc__r! r$ r r r% � r r r r ! s( � �� �L��K�IM�"�(�"�'r r c � � e Zd ZdZdZdZd� Zy)�MySQLNativePasswordAuthPluginzBClass implementing the MySQL Native Password authentication pluginF�mysql_native_passwordc � � | j st j d� �| j sy| j }t | j � r| j j d� }n| j }t r"t |� } t | j � }n|}| j }d} t |� j � }t |� j � }t ||z � j � }t r4t ||� D ��cg c] \ }}t |� t |� z �� } }}n!t ||� D ��cg c] \ }}||z �� } }}t j dg| ��� }|S # t $ r t j d� �w xY wc c}}w c c}}w # t $ r)} t j dj! | � � �d} ~ ww xY w)z;Prepares and returns password as native MySQL 4.1+ passwordz"Missing authentication data (seed)r zutf-8zAuthentication data incorrectN�20BzFailed scrambling password; {0})r r r"