Docs restructure, code review, gatherer reliability, JWT key fail-closed

Documentation
- Three levels: DOCS/General (overview, configuration), DOCS/Deployment
  (choose a method, first steps), details per method in Containers/ and
  System_Services/; new root README and DOCS/README map.
- Remove superseded pages (Deployment.md, Deployment_Docker/Native.md, Index.md);
  split the two scenario guides by section.
- Isolate the Timeweb/Hysteria2 records in DEPLOYMENTS/timeweb-hysteria2/
  (not linked from DOCS, listed in .graphifyignore).
- Add DOCS/code_review/ with a time-stamped analysis of the code base.

Gatherer (BUG-02, BUG-03)
- Session key (CN, address, connected_since_ts), baseline from the
  active_sessions snapshot, grace period for sessions missing from the status.
- Status file integrity (TITLE/TIME/END) and freshness; a torn read skips the tick.
- Cache applied after commit; main loop survives exceptions, backs off, and
  stops cleanly on SIGTERM/SIGINT; new client rows start with the first
  frame's totals; five tests.

JWT signing key (SEC-01)
- No built-in default: Core and Profiler refuse to start with a missing,
  placeholder or short (< 32) key; shipped config.ini has an empty value.
- Same rule in install.sh, update.sh (issues a new key when missing or weak),
  docker lib/entrypoint; five tests, conftest.py for the test key.

Each change has a plan and a summary under DOCS/Changes/.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-05 20:30:45 +03:00
1 parent f95a0b63e6
commit ad6995bb63
85 files changed
+2805 -1280

No files matched your search

+18 -8
View File
@@ -10,6 +10,7 @@ import pyotp
import bcrypt
from functools import wraps
from db import DatabaseManager
from secret_key import resolve_secret_key, SecretKeyError
import io
@@ -41,18 +42,27 @@ class OpenVPNAPI:
return fallback
def __init__(self, config_file='config.ini'):
self.db_manager = DatabaseManager(config_file)
self.db_manager.init_database()
self.config = configparser.ConfigParser()
self.config.read(config_file)
# Security: fail closed on a missing/weak signing key, before any DB work or admin creation
try:
self.secret_key, key_source = resolve_secret_key(
os.getenv('OVPMON_API_SECRET_KEY'),
self.config.get('api', 'secret_key', fallback=None),
os.getenv('OVPMON_SECRET_KEY'))
except SecretKeyError as e:
logger.critical(f"Refusing to start: {e}")
raise SystemExit(1)
logger.info(f"JWT secret key loaded from {key_source}")
app.config['SECRET_KEY'] = self.secret_key
self.db_manager = DatabaseManager(config_file)
self.db_manager.init_database()
# Paths
self.public_ip = self.get_config_value('openvpn_monitor', 'public_ip', fallback='')
# Security
self.secret_key = self.get_config_value('api', 'secret_key', fallback='ovpmon-secret-change-me')
app.config['SECRET_KEY'] = self.secret_key
# Ensure at least one user exists
self.ensure_default_admin()