PATH:
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
defence360agent
/
wordpress
/
__pycache__
/
Editing: proxy_auth.cpython-311.pyc
� ���i� � �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 j k S )Ng ) �os�stat�JWT_SECRET_PATH�st_mtime�FileNotFoundErrorr �now� timestamp�SECRET_EXPIRATION_TTL�seconds)r r s �Y/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/wordpress/proxy_auth.py�is_secret_expiredr sq � �!��w��'�'�� �=���� � � � ��������� ���� � �"�"�X�-�0E�0M�M�s �# �2�2c � � K � t t � � } t � d� � t j d� � }| j � ddd�� � | � d�� � t | |dt t � � d� � � dS # t $ r&}t � d |� � Y d}~dS d}~ww xY w)�.Load JWT secret from the configured file path.zRotating proxy auth secret� i� T)�mode�parents�exist_oki� )r ���)�uid�backup�permissionsz&Got error while rotating the secret %sN)r r �logger�info�secrets�token_bytes�parent�mkdir�touchr �str�JWT_SECRET_PATH_OLD� Exception�error)�secret_path�stub_secret�es r � rotate_secretr3 &