typarr.middlewareΒΆ

HTTP middleware for authentication enforcement.

class typarr.middleware.AuthMiddleware(app: Callable[[MutableMapping[str, Any], Callable[[], Awaitable[MutableMapping[str, Any]]], Callable[[MutableMapping[str, Any]], Awaitable[None]]], Awaitable[None]], dispatch: Callable[[Request, Callable[[Request], Awaitable[Response]]], Awaitable[Response]] | None = None)ΒΆ

Redirect unauthenticated requests to the login page (or return 401 for API calls).

async dispatch(request, call_next)ΒΆ

Check session for authentication before forwarding the request.

typarr.middleware.register_middleware(app: FastAPI) NoneΒΆ

Attach session and auth middleware to the application.

Middleware executes in reverse registration order, so auth runs first (registered last) and the session is available when it checks the cookie.