File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/auth/__pycache__/__init__.cpython-310.pyc
o
�N�g�S � @ s� d Z ddlZddlZddlZddlZddlmZmZ ddlZ ddl
Z ddlZ ddlZ ddl
Z ddlZ ddlZ ddlZ ddlZ ddlZ ddlZ ddlZ e�e�Zeg d��ZG dd� d�ZG dd� d�ZG d d
� d
�ZdS )z�
Salt's pluggable authentication system
This system allows for authentication to be managed in a module pluggable way
so that any external authentication system can be used inside of Salt
� N)�Iterable�Mapping)�client�cmd�eauthZfunZgather_job_timeout�kwarg�match�metadataZprint_event�rawZyield_pub_datac @ s� e Zd ZdZd&dd�Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd � Zd&d!d"�Zd'd$d%�ZdS )(�LoadAuthzH
Wrap the authentication system to handle peripheral components
Nc C s@ || _ d| _tj�|�| _tj�|�| _|ptjj� |�| _
d S )Ng �?)�opts�max_fail�salt�loader�auth�eauth_tokens�tokens�utilsZminionsZ CkMinions� ckminions)�selfr r � r �F/opt/saltstack/salt/lib/python3.10/site-packages/salt/auth/__init__.py�__init__: s
zLoadAuth.__init__c C sd d|vrdS d� |d �}|| jvrdS ztjj�| j| �d d }|| W S ty1 Y dS w )z�
Return the primary name associate with the load, if an empty string
is returned then the load does not match the function
r � �{}.auth�argsr )�formatr r r r �
arg_lookup�
IndexError)r �load�fstrZ pname_argr r r � load_nameA s
�zLoadAuth.load_namec
s� d|vrdS d� |d �}|| jvrdS g d�� � fdd�|�� D �}tjjj| j| |td�}zd|v rD| j| |d i |d ��W S | j| |d � W S tyf } z
t �
d
|� W Y d}~dS d}~ww )z�
Return the token and set the cache data for use
Do not call this directly! Use the time_auth method to overcome timing
attacks
r Fr )�username�passwordr �tokenc s i | ]\}}|� v r||�qS r r )�.0�key�value�Z_validr r �
<dictcomp>` s z(LoadAuth.__auth_call.<locals>.<dictcomp>�Zexpected_extra_kws�kwargsr �Authentication module threw %sN)r r �itemsr r r �format_call�AUTH_INTERNAL_KEYWORDS� Exception�log�debug)r r r �_load�fcall�er r( r Z__auth_callQ s&