%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/auth/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/auth/mysql.pyo

�
���^c@@sdZddlmZmZmZddlZeje�Zy8ddl	Z	ddl
Z	ddlZ	ddlm
Z
Wnyek
r�yNddlZej�ddl	Z	ddl
Z	ddlZ	ddlm
Z
Wq�ek
r�dZ	q�XnXd�Zd�Zd�ZdS(u
Provide authentication using MySQL.

When using MySQL as an authentication backend, you will need to create or
use an existing table that has a username and a password column.

To get started, create a simple table that holds just a username and
a password. The password field will hold a SHA256 checksum.

.. code-block:: sql

    CREATE TABLE `users` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `username` varchar(25) DEFAULT NULL,
      `password` varchar(70) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

To create a user within MySQL, execute the following statement.

.. code-block:: sql

    INSERT INTO users VALUES (NULL, 'diana', SHA2('secret', 256))

.. code-block:: yaml

    mysql_auth:
      hostname: localhost
      database: SaltStack
      username: root
      password: letmein
      auth_sql: 'SELECT username FROM users WHERE username = "{0}" AND password = SHA2("{1}", 256)'

The `auth_sql` contains the SQL that will validate a user to ensure they are
correctly authenticated. This is where you can specify other SQL queries to
authenticate users.

Enable MySQL authentication.

.. code-block:: yaml

    external_auth:
      mysql:
        damian:
          - test.*

:depends:   - MySQL-python Python module
i(tabsolute_importtprint_functiontunicode_literalsN(tOperationalErrorcC@s"tt�tdkrdndfS(u:
    Confirm that a python mysql client is installed.
    u!No python mysql client installed.uN(tbooltMySQLdbtNone(((s3/usr/lib/python2.7/site-packages/salt/auth/mysql.pyt__virtual__LscC@s�i}y^tdd|d<tdd|d<tdd|d<tdd|d<tdd|d<Wn$tk
r�}tjd|�dSX|S(	u'
    Grab MySQL Connection Details
    u
mysql_authuhostnameuusernameupasswordudatabaseuauth_sqlu%s does not existN(t__opts__tKeyErrortlogterrorR(t	conn_infote((s3/usr/lib/python2.7/site-packages/salt/auth/mysql.pyt__get_connection_infoSscC@s�t�}|dkrtSy,tj|d|d|d|d�}Wn!tk
rh}tj|�tSX|j�}|j	|dj
||��|jdkr�tStS(u/
    Authenticate using a MySQL user table
    uhostnameuusernameupasswordudatabaseuauth_sqliN(
RRtFalseRtconnectRR
RtcursortexecutetformattrowcounttTrue(tusernametpasswordt_infotconnR
tcur((s3/usr/lib/python2.7/site-packages/salt/auth/mysql.pytauthgs 	

(t__doc__t
__future__RRRtloggingt	getLoggert__name__R
RtMySQLdb.cursorstMySQLdb.converterstMySQLdb.connectionsRtImportErrortpymysqltinstall_as_MySQLdbtMySQLdb.errRRRR(((s3/usr/lib/python2.7/site-packages/salt/auth/mysql.pyt<module>2s*


		

Zerion Mini Shell 1.0