feat(serve): add service allowlist for global and per-user access control

Allow server operators to restrict which services are exposed via the API using serve.services (global) and serve.users.<key>.services (per-user).
Effective access is the intersection of both when both are set. Unlisted services return the same error as non-existent ones to prevent enumeration.
This commit is contained in:
imSp4rky
2026-03-31 23:06:07 -06:00
parent 8a714d6455
commit 3aaca77c48
5 changed files with 82 additions and 13 deletions
+10
View File
@@ -143,6 +143,16 @@ def serve(
if remote_only:
api_only = True
global_services = config.serve.get("services")
if global_services:
log.info(f"Global service allowlist: {', '.join(global_services)}")
users = config.serve.get("users", {})
for user_key, user_cfg in (users.items() if isinstance(users, dict) else []):
user_services = user_cfg.get("services") if isinstance(user_cfg, dict) else None
if user_services:
username = user_cfg.get("username", user_key[:8] + "...")
log.info(f"User '{username}' restricted to services: {', '.join(user_services)}")
if api_only:
log.info("Starting REST API server (pywidevine/pyplayready CDM disabled)")
if no_key: