File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/auth/__pycache__/file.cpython-310.pyc
Back
o ;jv! � @ sz d Z ddlZddlZddlZddlZe�e�ZdZ dd� Z dd� Zdd � Zd d� Z dd � Zdd� Zeeed�Zdd� ZdS )a� Provide authentication using local files .. versionadded:: 2018.3.0 The `file` auth module allows simple authentication via local files. Different filetypes are supported, including: 1. Text files, with passwords in plaintext or hashed 2. Apache-style htpasswd files 3. Apache-style htdigest files .. note:: The ``python-passlib`` library is required when using a ``^filetype`` of ``htpasswd`` or ``htdigest``. The simplest example is a plaintext file with usernames and passwords: .. code-block:: yaml external_auth: file: ^filename: /etc/insecure-user-list.txt gene: - .* dean: - test.* In this example the ``/etc/insecure-user-list.txt`` file would be formatted as so: .. code-block:: text dean:goneFishing gene:OceanMan ``^filename`` is the only required parameter. Any parameter that begins with a ``^`` is passed directly to the underlying file authentication function via ``kwargs``, with the leading ``^`` being stripped. The text file option is configurable to work with legacy formats: .. code-block:: yaml external_auth: file: ^filename: /etc/legacy_users.txt ^filetype: text ^hashtype: md5 ^username_field: 2 ^password_field: 3 ^field_separator: '|' trey: - .* This would authenticate users against a file of the following format: .. code-block:: text 46|trey|16a0034f90b06bf3c5982ed8ac41aab4 555|mike|b6e02a4d2cb2a6ef0669e79be6fd02e4 2001|page|14fce21db306a43d3b680da1a527847a 8888|jon|c4e94ba906578ccf494d71f45795c6cb .. note:: The :py:func:`hashutil.digest <salt.modules.hashutil.digest>` execution function is used for comparing hashed passwords, so any algorithm supported by that function will work. There is also support for Apache-style ``htpasswd`` and ``htdigest`` files: .. code-block:: yaml external_auth: file: ^filename: /var/www/html/.htusers ^filetype: htpasswd cory: - .* When using ``htdigest`` the ``^realm`` must be set: .. code-block:: yaml external_auth: file: ^filename: /var/www/html/.htdigest ^filetype: htdigest ^realm: MySecureRealm cory: - .* � N�filec C s t S )N)�__virtualname__� r r �B/opt/saltstack/salt/lib/python3.10/site-packages/salt/auth/file.py�__virtual__m s r c C s� dddddd�} t d t D ]}|�d�r#t d t | | |dd � <