updated to newest version, dlhd support

This commit is contained in:
UrloMythus
2025-05-18 22:09:07 +02:00
parent 1bdfe198b5
commit 4b5891457e
9 changed files with 486 additions and 24 deletions

View File

@@ -0,0 +1,26 @@
from fastapi import Request, Response
from starlette.middleware.base import BaseHTTPMiddleware
from mediaflow_proxy.configs import settings
class UIAccessControlMiddleware(BaseHTTPMiddleware):
"""Middleware that controls access to UI components based on settings."""
async def dispatch(self, request: Request, call_next):
path = request.url.path
# Block access to home page
if settings.disable_home_page and (path == "/" or path == "/index.html"):
return Response(status_code=403, content="Forbidden")
# Block access to API docs
if settings.disable_docs and (path == "/docs" or path == "/redoc" or path.startswith("/openapi")):
return Response(status_code=403, content="Forbidden")
# Block access to speedtest UI
if settings.disable_speedtest and path.startswith("/speedtest"):
return Response(status_code=403, content="Forbidden")
return await call_next(request)