Remove hardcoded Yeastar credentials

This commit is contained in:
root 2026-08-14 17:20:50 +00:00
parent 938b79a67e
commit fc10d2ef8b
3 changed files with 40 additions and 11 deletions

View file

@ -9,3 +9,10 @@ MARIADB_USER=gmao
MARIADB_PASSWORD=CHANGE_ME
DOCKER_GMAO_WORKDIR=/app
DOCKER_GMAO_ENVFILE=/app/.env.docker
YEASTAR_DND_ENABLED=0
YEASTAR_BASE_URL=https://votre-yeastar.example
YEASTAR_USERNAME=CHANGE_ME
YEASTAR_PASSWORD=CHANGE_ME
YEASTAR_DND_REFRESH_SECONDS=2
YEASTAR_DND_RESET_DELAY_SECONDS=3
YEASTAR_DND_EXCLUDED_EXTENSIONS=

View file

@ -13,6 +13,15 @@ DATABASE_URL=mysql+pymysql://gmao:${MARIADB_PASSWORD}@mariadb/gmao_db?charset=ut
# Dossier des uploads (chemin absolu)
UPLOAD_FOLDER=/app/app_new/uploads
# Watchdog Yeastar DND (optionnel, desactive par defaut)
YEASTAR_DND_ENABLED=0
YEASTAR_BASE_URL=https://votre-yeastar.example
YEASTAR_USERNAME=CHANGE_ME
YEASTAR_PASSWORD=CHANGE_ME
YEASTAR_DND_REFRESH_SECONDS=2
YEASTAR_DND_RESET_DELAY_SECONDS=3
YEASTAR_DND_EXCLUDED_EXTENSIONS=
# Variables optionnelles pour Docker Compose
MARIADB_ROOT_PASSWORD=CHANGE_ME
MARIADB_DATABASE=gmao_db

View file

@ -1,13 +1,7 @@
"""Watchdog DND P520 - Surveillance continue - version autonome.
CONFIGURATION MANUELLE EN CLAIR (a remplacer):
YEASTAR_USERNAME = "admin"
YEASTAR_PASSWORD = "motdepasse"
"""
YEASTAR_USERNAME = '116'
YEASTAR_PASSWORD = '***REMOVED-YEASTAR-CREDENTIAL***'
"""Watchdog DND P520 - Surveillance continue - version autonome."""
import base64
import hashlib
import os
import sys
import time
import uuid
@ -103,8 +97,24 @@ class YeastarClient:
return False
def load_config():
"""Charge la config en clair."""
return {'enabled': True, 'refresh_seconds': 2, 'reset_delay_seconds': 3, 'excluded_extensions': [], 'base_url': 'https://telclg.noellet.ovh', 'username': YEASTAR_USERNAME, 'password': YEASTAR_PASSWORD}
"""Charge la configuration depuis l'environnement, sans secret dans le code."""
base_url = os.environ.get('YEASTAR_BASE_URL', '').strip()
username = os.environ.get('YEASTAR_USERNAME', '').strip()
password = os.environ.get('YEASTAR_PASSWORD', '')
explicitly_enabled = os.environ.get('YEASTAR_DND_ENABLED', '0') == '1'
return {
'enabled': explicitly_enabled and bool(base_url and username and password),
'refresh_seconds': int(os.environ.get('YEASTAR_DND_REFRESH_SECONDS', '2')),
'reset_delay_seconds': int(os.environ.get('YEASTAR_DND_RESET_DELAY_SECONDS', '3')),
'excluded_extensions': [
value.strip()
for value in os.environ.get('YEASTAR_DND_EXCLUDED_EXTENSIONS', '').split(',')
if value.strip()
],
'base_url': base_url,
'username': username,
'password': password,
}
def log_dnd(message, level='info'):
from datetime import datetime
@ -123,6 +133,9 @@ def run_watchdog():
"""Boucle principale du watchdog."""
log_dnd('[DND] Demarrage watchdog')
config = load_config()
if not config['enabled']:
log_dnd('[DND] Watchdog desactive ou configuration Yeastar incomplete')
return True
log_dnd(f"[DND] Config: enabled={config.get('enabled')}, url={config.get('base_url')}, user={config.get('username')}")
client = YeastarClient(config['base_url'], config['username'], config['password'])
result = client.login()