mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-24 09:55:12 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user