mirror of
https://github.com/UrloMythus/UnHided.git
synced 2026-04-11 11:50:51 +00:00
updated to newest version, dlhd support
This commit is contained in:
26
mediaflow_proxy/middleware.py
Normal file
26
mediaflow_proxy/middleware.py
Normal 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)
|
||||
|
||||
Reference in New Issue
Block a user