v8.0.1: Refactor password handling and integrate group_id

Enhance function signatures to include group_id parameter for fetching settings in a multi-group context. Additionally, improve password handling by cleaning up special characters to ensure proper authentication.
pull/399/head
Aidaho 2024-09-13 13:11:10 +03:00
parent 6004147073
commit 202513fcfd
2 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,7 @@
from typing import Union
import requests
from flask import render_template, request
from flask import render_template
from flask_jwt_extended import get_jwt
from flask_jwt_extended import verify_jwt_in_request
@ -191,7 +193,7 @@ def check_service_config(server_ip: str, server_id: int, service: str) -> None:
def overview_backends(server_ip: str, service: str) -> str:
def overview_backends(server_ip: str, service: str) -> Union[str, dict]:
import app.modules.config.config as config_mod
if service not in ('nginx', 'apache'):
@ -236,11 +238,12 @@ def get_overview_last_edit(server_ip: str, service: str) -> str:
return f'error: Cannot get last date {e} for server {server_ip}'
def get_stat_page(server_ip: str, service: str) -> str:
stats_user = sql.get_setting(f'{service}_stats_user')
stats_pass = sql.get_setting(f'{service}_stats_password')
stats_port = sql.get_setting(f'{service}_stats_port')
stats_page = sql.get_setting(f'{service}_stats_page')
def get_stat_page(server_ip: str, service: str, group_id: int) -> str:
stats_user = sql.get_setting(f'{service}_stats_user', group_id=group_id)
stats_pass = sql.get_setting(f'{service}_stats_password', group_id=group_id)
stats_pass = stats_pass.replace("'", "")
stats_port = sql.get_setting(f'{service}_stats_port', group_id=group_id)
stats_page = sql.get_setting(f'{service}_stats_page', group_id=group_id)
try:
response = requests.get(f'http://{server_ip}:{stats_port}/{stats_page}', auth=(stats_user, stats_pass), timeout=5)

View File

@ -13,6 +13,7 @@ import app.modules.roxywi.common as roxywi_common
def stat_page_action(server_ip: str, group_id: int) -> bytes:
haproxy_user = sql.get_setting('haproxy_stats_user', group_id=group_id)
haproxy_pass = sql.get_setting('haproxy_stats_password', group_id=group_id)
haproxy_pass = haproxy_pass.replace("'", "")
stats_port = sql.get_setting('haproxy_stats_port', group_id=group_id)
stats_page = sql.get_setting('haproxy_stats_page', group_id=group_id)