File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/auth/__pycache__/__init__.cpython-310.pyc
o
;j�] � @ 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"� Zd#d$� Zd%d&� 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 s� t | d�r| jdurt | jd�r| j�� i | _t | d�r0| jdur0t | jd�r-| j�� i | _t | d�r\| jdur^t | jd�rW| jjdurWt | jjd�rS| jj�� d| j_d| _dS dS dS )z$
Clean up resources
r N�destroyr r �cache)�hasattrr r r r r �r r r r r A s
�zLoadAuth.destroyc C s | S �Nr r r r r � __enter__T s zLoadAuth.__enter__c G s | � � d S r )r )r �argsr r r �__exit__W s zLoadAuth.__exit__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 � �{}.authr r )�formatr r r r �
arg_lookup�
IndexError)r �load�fstrZ pname_argr r r � load_nameZ 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"