Module Expr Str ImportFrom alias Import alias Import alias identifier TryExcept body Import alias Assign NameStore NameLoad handlers ExceptHandler type NameLoad name NameStore body Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Str FunctionDef arguments args defaults body If NameLoad body Return NameLoad Return NameLoad decorator_list FunctionDef arguments args defaults body Expr Str Global identifier If CompareIsNot NameLoad NameLoad body Return If CompareIn Str SubscriptLoad SubscriptLoad NameLoad Index Str Index Str body Assign NameStore SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num Assign NameStore Call AttributeLoad Str attr SubscriptLoad Call AttributeLoad NameLoad attr Str Slice Num Num Expr Call NameLoad NameLoad Call NameLoad Call NameLoad Str Assign NameStore Call AttributeLoad Str attr NameLoad Assign NameStore Call NameLoad NameLoad If CompareGtE AttributeLoad NameLoad attr TupleLoad Num Num body Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Import alias Expr Call NameLoad Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr keyword NameLoad keyword NameLoad If CompareIsNot NameLoad NameLoad body If AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str Assign NameStore SubscriptLoad Call NameLoad NameLoad Index NameLoad If CompareIsNot NameLoad NameLoad body Assign SubscriptStore SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index NameLoad NameLoad Return NameLoad orelse Expr Call AttributeLoad NameLoad attr Str Return NameLoad decorator_list FunctionDef arguments args NameParam defaults NameLoad body Expr Str Expr Call NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr orelse Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad Assign NameStore Dict For NameStore NameLoad body If CompareNotIn AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Assign SubscriptStore NameLoad Index AttributeLoad AttributeLoad NameLoad attr attr ListLoad If BoolOpAnd UnaryOpNot AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad SubscriptLoad NameLoad Index AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad NameLoad attr orelse If BoolOpAnd AttributeLoad NameLoad attr UnaryOpNot AttributeLoad NameLoad attr body Expr Call AttributeLoad SubscriptLoad NameLoad Index AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad NameLoad attr orelse Assign NameStore NameLoad For NameStore SubscriptLoad NameLoad Index AttributeLoad AttributeLoad NameLoad attr attr body If Call NameLoad NameLoad NameLoad body If CompareIn AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad SubscriptLoad SubscriptLoad NameLoad Index AttributeLoad AttributeLoad NameLoad attr attr Index AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Assign NameStore NameLoad If UnaryOpNot NameLoad body Expr Call AttributeLoad SubscriptLoad NameLoad Index AttributeLoad AttributeLoad NameLoad attr attr attr Dict AttributeLoad NameLoad attr ListLoad AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr Call NameLoad NameLoad Return NameLoad decorator_list
N/A N/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(auth.User)
        minion_matcher = models.CharField()
        minion_fn = models.CharField()

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'.
 __future__ absolute_import N/A logging N/A salt.ext.six six N/A N/A N/A django N/A HAS_DJANGO True N/A N/A N/A Exception N/A exc N/A N/A HAS_DJANGO False N/A DJANGO_AUTH_CLASS None N/A log N/A N/A logging getLogger __name__ N/A __virtualname__ django __virtual__ N/A N/A N/A N/A N/A HAS_DJANGO N/A N/A __virtualname__ N/A False N/A django_auth_setup N/A N/A N/A N/A N/A 
    Prepare the connection to the Django authentication framework
     N/A DJANGO_AUTH_CLASS N/A N/A DJANGO_AUTH_CLASS None N/A N/A N/A N/A ^model N/A N/A __opts__ N/A external_auth N/A django N/A N/A django_model_fullname N/A N/A N/A __opts__ N/A external_auth N/A django N/A ^model N/A django_model_name N/A N/A N/A django_model_fullname split . N/A -1 N/A django_module_name N/A N/A . join N/A N/A N/A django_model_fullname split . N/A 0 -1 N/A N/A __import__ django_module_name N/A globals N/A locals SaltExternalAuthModel N/A DJANGO_AUTH_CLASS_str N/A N/A django_auth_module.{0} format django_model_name N/A DJANGO_AUTH_CLASS N/A eval DJANGO_AUTH_CLASS_str N/A N/A N/A django VERSION N/A 1 7 N/A N/A N/A N/A django setup N/A auth N/A N/A username password N/A N/A N/A 
    Simple Django auth
     N/A django.contrib.auth N/A N/A django_auth_setup N/A user N/A N/A N/A N/A django contrib auth authenticate username username password password N/A N/A user None N/A N/A N/A user is_active N/A N/A N/A N/A log debug Django authentication successful N/A auth_dict_from_db N/A N/A retrieve_auth_entries username N/A username N/A N/A auth_dict_from_db None N/A N/A N/A N/A N/A __opts__ N/A external_auth N/A django N/A username auth_dict_from_db N/A True N/A N/A N/A N/A log debug Django authentication: the password is valid but the account is disabled. N/A False N/A retrieve_auth_entries N/A N/A u N/A None N/A N/A 

    :param u: Username to filter for
    :return: Dictionary that can be slotted into the ``__opts__`` structure for
        eauth that designates the user associated ACL

    Database records such as:

    ===========  ====================     =========
    username     minion_or_fn_matcher     minion_fn
    ===========  ====================     =========
    fred                                  test.ping
    fred         server1                  network.interfaces
    fred         server1                  raid.list
    fred         server2                  .*
    guru         .*
    smartadmin   server1                  .*
    ===========  ====================     =========

    Should result in an eauth config such as:

    .. code-block:: yaml

        fred:
          - test.ping
          - server1:
              - network.interfaces
              - raid.list
          - server2:
              - .*
        guru:
          - .*
        smartadmin:
          - server1:
            - .*

     N/A N/A django_auth_setup N/A N/A u None N/A N/A db_records N/A N/A N/A DJANGO_AUTH_CLASS objects all N/A N/A db_records N/A N/A N/A DJANGO_AUTH_CLASS objects filter user_fk__username u N/A auth_dict N/A N/A a db_records N/A N/A N/A N/A N/A a user_fk username auth_dict N/A N/A N/A auth_dict N/A N/A N/A a user_fk username N/A N/A N/A N/A N/A a minion_or_fn_matcher N/A a minion_fn N/A N/A N/A N/A N/A auth_dict N/A N/A N/A a user_fk username append N/A a minion_fn N/A N/A N/A N/A a minion_or_fn_matcher N/A N/A a minion_fn N/A N/A N/A N/A N/A auth_dict N/A N/A N/A a user_fk username append N/A a minion_or_fn_matcher N/A N/A found False N/A d N/A auth_dict N/A N/A N/A a user_fk username N/A N/A N/A isinstance d dict N/A N/A N/A N/A a minion_or_fn_matcher N/A N/A six iterkeys d N/A N/A N/A N/A N/A N/A auth_dict N/A N/A N/A a user_fk username N/A N/A a minion_or_fn_matcher append N/A a minion_fn N/A found True N/A N/A found N/A N/A N/A N/A N/A auth_dict N/A N/A N/A a user_fk username append N/A N/A a minion_or_fn_matcher N/A N/A a minion_fn N/A N/A N/A log debug N/A N/A django auth_dict is {0} format N/A repr auth_dict N/A auth_dict N/A