🔐 Sid Gifari File Manager Pro
v8.0.5 | 2026-06-15 08:00:49 | PHP 8.1.34
📂
/ (Root)
/
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
defence360agent
/
wordpress
/
__pycache__
📍 /opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/wordpress/__pycache__
🔄 Refresh
✏️
Editing: proxy_auth.cpython-311.pyc
Read Only
� *��[�(�� �N � d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlmZ d dl m Z d dlmZ d dl mZmZmZ ej e� � Z ed�� � Zd Zd ZdZ ed� � � Zd� Zd� Z ed� � defd�� � Zdededefd�Zdededdfd�Z dej! ddfd�Z"dS )� N)�datetime� timedelta)� lru_cache)�Path)�atomic_rewrite)�ensure_site_data_directory�format_php_with_embedded_json�!write_plugin_data_file_atomically�H )�hoursz#/etc/imunify-agent-proxy/jwt-secretz'/etc/imunify-agent-proxy/jwt-secret.oldzimunify-agent-proxy� )�daysc �� � t j t � � } | j }n# t $ r d}Y nw xY wt j � � � � � |z t � � � k S )Ng ) �os�stat�JWT_SECRET_PATH�st_mtime�FileNotFoundErrorr �now� timestamp�SECRET_EXPIRATION_TTL� total_seconds)r r s �Y/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/wordpress/proxy_auth.py�is_secret_expiredr s| � �!��w��'�'�� �=���� � � � ��������� ���� � �"�"�X�-� � -� -� /� /� 0�s �# �2�2c � �� K � t t � � } t � d� � t j d� � }| j � ddd�� � | � d�� � t | |dt t � � d� � � t � � � dS # t $ r(}t � d |d�� � Y d}~dS d}~ww xY w) z�Rotate the proxy JWT secret on disk: backup current to .old and write a fresh 32-byte secret atomically. Invalidates the in-process cache so subsequent generate_token() calls read the new secret. zRotating proxy auth secret� i� T)�mode�parents�exist_oki� )r ���)�uid�backup�permissionsz'Got error while rotating the secret: %s)�exc_infoN)r r �logger�info�secrets�token_bytes�parent�mkdir�touchr �str�JWT_SECRET_PATH_OLD�load_secret_from_file�cache_clear� Exception�error)�secret_path�stub_secret�es r � rotate_secretr5 * s � � � � ��'�'�K� ����0�1�1�1��)�"�-�-���� � �e�T�D� �I�I�I����u��%�%�%������*�+�+�� � � � � �)�)�+�+�+�+�+��� � � ����5�q�4� � � � � � � � � � ����� ���s �B B: �: C,�C'�'C,� �returnc �^ � t t d� � 5 } | � � � � � � cddd� � S # 1 swxY w Y dS # t $ r" t � dt � � � t $ r!}t � d|� � � d}~ww xY w)z.Load JWT secret from the configured file path.�rbNzJWT secret file not found at %szFailed to read JWT secret: %s)�openr �read�stripr r% r1 r0 )�fr4 s r r. r. C s� � �� �/�4� (� (� $�A��6�6�8�8�>�>�#�#� $� $� $� $� $� $� $� $� $� $� $� $���� $� $� $� $� $� $��� � � ����6��H�H�H� �� � � ����4�a�8�8�8� ��������s9 �A �&A �A � A�A �A�A �4B,�B'�'B,�username�docrootc � � t j � � t z }|| |d�} ddl}|� |t � � d�� � }|S # t $ r!}t � d|� � � d}~ww xY w)z� Generate a JWT token for the given username and docroots. Args: username: The username for the token docroot: document root paths the user has access to Returns: The JWT token string )�expr>