media-rip/backend/app/routers/system.py
xpltd 1592407658 First-run admin setup wizard, password persistence, forced setup gate
- Admin enabled by default (was opt-in via env var)
- New /admin/status (public) and /admin/setup (first-run only) endpoints
- Setup endpoint locked after first use (returns 403)
- Admin password persisted to SQLite config table (survives restarts)
- Change password now persists to DB (was in-memory only)
- Frontend router guard forces /admin redirect until setup is complete
- AdminSetup.vue wizard: username + password + confirm
- Public config exposes admin_enabled/admin_setup_complete for frontend
- TLS warning only fires when password is actually configured
2026-03-21 20:01:13 -05:00

34 lines
1.2 KiB
Python

"""System endpoints — public (non-sensitive) configuration for the frontend."""
from __future__ import annotations
import logging
from fastapi import APIRouter, Request
logger = logging.getLogger("mediarip.system")
router = APIRouter(tags=["system"])
@router.get("/config/public")
async def public_config(request: Request) -> dict:
"""Return the safe subset of application config for the frontend.
Reads from the live AppConfig which includes persisted admin settings.
"""
config = request.app.state.config
return {
"session_mode": config.session.mode,
"default_theme": config.ui.default_theme,
"welcome_message": config.ui.welcome_message,
"purge_enabled": config.purge.enabled,
"max_concurrent_downloads": config.downloads.max_concurrent,
"default_video_format": getattr(request.app.state, "_default_video_format", "auto"),
"default_audio_format": getattr(request.app.state, "_default_audio_format", "auto"),
"privacy_mode": config.purge.privacy_mode,
"privacy_retention_hours": config.purge.privacy_retention_hours,
"admin_enabled": config.admin.enabled,
"admin_setup_complete": bool(config.admin.password_hash),
}