Файловый менеджер - Редактировать - /opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/__pycache__/proxy_auth.cpython-311.pyc
Назад
� �l�hJ � �r � d Z ddlZddlZddlZddlZddlZddlZddlmZmZ ddl m Z ddlmZ ddl mZmZ ddlmZ ddlmZ ej e� � Z ed � � � ZdZdZd Z ed�� � Zd� Zd� Z e d� � defd�� � Zde de de fd�Z!dede"fd�Z#de de"ddfd�Z$dej% ddfd�Z&dS )u This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see <https://www.imunify360.com/legal/eula> � N)�datetime� timedelta)� lru_cache)�Path)�atomic_rewrite� check_run)�get_data_dir��!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 �N/opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/proxy_auth.py�is_secret_expiredr / sq � �!��w��'�'�� �=���� � � � ��������� ���� � �"�"�X�-�0E�0M�M�s �# �2�2c �� � t t � � } t � d� � t j d� � }| j � ddd�� � | � d�� � t | |dt t � � d� � � t d dt g� � d S # t $ r&}t � d|� � Y d }~d S 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�permissions� systemctl�restartz&Got error while rotating the secret %sN)r r �logger�info�secrets�token_bytes�parent�mkdir�touchr �str�JWT_SECRET_PATH_OLDr �PROXY_SERVICE_NAME� Exception�error)�secret_path�stub_secret�es r � rotate_secretr7 ; s � ���'�'�K�B����(� � � � �)�"�-�-���� � �e�T�D� �I�I�I����u��%�%�%������*�+�+�� � � � � �;� �+=�>�?�?�?�?�?��� B� B� B����=�q�A�A�A�A�A�A�A�A�A�����B���s �BB6 �6 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)r �rbNzJWT secret file not found at %szFailed to read JWT secret: %s)�openr �read�stripr r( r3 r2 )�fr6 s r �load_secret_from_filer@ Q 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�} t j |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 )�exprA � site_path�HS256)� algorithmz Failed to generate JWT token: %sN) r �utcnow�DEFAULT_TOKEN_EXPIRATION�jwt�encoder@ r2 r( r3 )rA rB �exp_time�claims�tokenr6 s r �generate_tokenrO _ s� � � �� � �#;�;�H��8�'� J� J�F��� �6�#8�#:�#:�g�N�N�N������ � � ����7��;�;�;� ��������s �$A � A3�A.�.A3�auth_file_path�gidc �* � t | |||� � dS )z0Synchronous function to write the auth.php file.Nr )rP �php_contentr# rQ s r �_write_auth_php_filerT v s � �%�n�k�3��L�L�L�L�L� rN c � �( K � t | � � � d{V ��}|dz }d|� d�}t j t ||||� � � d{V �� t � d| |� � dS # t $ r"}t � d| |� � � d}~ww xY w)z� Create the auth.php file in the site's imunify-security directory. Args: site: WPSite instance token: JWT token string uid, gid: int used for file creation Nzauth.phpz!<?php return array( 'token' => 'z', ); z'Created auth.php file for site %s at %sz.Failed to create auth.php file for site %s: %s)r �asyncio� to_threadrT r( r) r2 r3 )�siterN r# rQ �data_dirrP rS r6 s r �create_auth_php_filer[ { s� � � � ��%�d�+�+�+�+�+�+�+�+��!�J�.����� � �� �� �.�+�s�C� � � � � � � � � � ���5�t�^� � � � � �� � � � ����E�t�Q�O�O�O� ��������s �AA% �% B�/B�B� user_infoc � �2 K � t |j t | j � � � � }t | ||j |j � � � d{V �� t � d| � � dS # t $ r"}t � d| |� � � d}~ww xY w)z� Set up authentication for a site by creating JWT token and auth.php file. Args: site: WPSite instance user_info: pwd.struct_passwd data Nz.Successfully set up authentication for site %sz/Failed to set up authentication for site %s: %s)rO �pw_namer/ rB r[ �pw_uid�pw_gidr( r) r2 r3 )rY r\ rN r6 s r �setup_site_authenticationra � s� � � � ���y�0�#�d�l�2C�2C�D�D��"��%��)�9�+;� � � � � � � � � � ���D�d�K�K�K�K�K��� � � ����=�t�Q� � � � ����� ���s �A$A* �* B�4B�B)'�__doc__rJ �loggingrW �pwdr r* r r � functoolsr �pathlibr �defence360agent.utilsr r �imav.wordpress.clir �imav.wordpress.utilsr � getLogger�__name__r( rI r r0 r1 r r r7 �bytesr@ r/ rO �intrT r[ � struct_passwdra � rU r �<module>rp s ��� �* � � � � ���� ���� � � � � � � � � ���� (� (� (� (� (� (� (� (� � � � � � � � � � � � � ;� ;� ;� ;� ;� ;� ;� ;� +� +� +� +� +� +� B� B� B� B� B� B� �� �8� $� $��$�9�2�.�.�.� �7��?� �*� �!� �q�)�)�)� � � � �B� B� B�, ��1��� �u� � � � �� ��S� �3� �3� � � � �.M�� M�c� M� M� M� M� �C� �3� �4� � � � �>��&�� �� � � � � rU
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка