File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/auth/__pycache__/django.cpython-310.pyc
o
�N�g� �
@ s� d Z ddlZddlZddlZzddlZddlmZ dZW n ey0 Z zdZW Y dZ [ ndZ [ ww da
e�e�Z
dZdd� Zd d
� Zdd� Zd
d� Zdd� ZdS )a�
Provide authentication using Django Web Framework
:depends: - Django Web Framework
Django authentication depends on the presence of the django framework in the
``PYTHONPATH``, the Django project's ``settings.py`` file being in the
``PYTHONPATH`` and accessible via the ``DJANGO_SETTINGS_MODULE`` environment
variable.
Django auth can be defined like any other eauth module:
.. code-block:: yaml
external_auth:
django:
fred:
- .*
- '@runner'
This will authenticate Fred via Django and allow him to run any execution
module and all runners.
The authorization details can optionally be located inside the Django database.
The relevant entry in the ``models.py`` file would look like this:
.. code-block:: python
class SaltExternalAuthModel(models.Model):
user_fk = models.ForeignKey(User, on_delete=models.CASCADE)
minion_or_fn_matcher = models.CharField(max_length=255)
minion_fn = models.CharField(max_length=255)
The :conf_master:`external_auth` clause in the master config would then look
like this:
.. code-block:: yaml
external_auth:
django:
^model: <fully-qualified reference to model class>
When a user attempts to authenticate via Django, Salt will import the package
indicated via the keyword ``^model``. That model must have the fields
indicated above, though the model DOES NOT have to be named
'SaltExternalAuthModel'.
� N)�
connectionTF�djangoc C s t rtS dS )NF)�
HAS_DJANGO�__virtualname__� r r �D/opt/saltstack/salt/lib/python3.10/site-packages/salt/auth/django.py�__virtual__I s r c C s&