fix(serve): use X-Secret-Key header for REST API auth to match pywidevine

Standardize on X-Secret-Key across all endpoints so RemoteClient, pywidevine CDM, and api-only mode all use the same auth header. Adds lightweight middleware for --api-only mode without pywidevine dep.
This commit is contained in:
Andy
2026-03-16 19:08:03 -06:00
parent b5325c9c47
commit bfab2ad5c9
3 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -1367,7 +1367,7 @@ async def session_create_handler(data: Dict[str, Any], request: Optional[web.Req
from unshackle.core.config import config as app_config
session_id = str(uuid_mod.uuid4())
api_key = request.headers.get("X-API-Key", "anonymous") if request else "anonymous"
api_key = request.headers.get("X-Secret-Key", "anonymous") if request else "anonymous"
api_key_hash = hashlib.sha256(api_key.encode()).hexdigest()[:12]
session_cache_tag = f"_sessions/{api_key_hash}/{session_id}/{normalized_service}"
+1 -1
View File
@@ -47,7 +47,7 @@ class RemoteClient:
if self._session is None:
self._session = requests.Session()
if self.api_key:
self._session.headers["X-API-Key"] = self.api_key
self._session.headers["X-Secret-Key"] = self.api_key
return self._session
def _request(self, method: str, endpoint: str, data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: