SecurityMiddleware¶
The SecurityMiddleware
class is the core component of FastAPI Guard that handles all security features.
Class Definition¶
class SecurityMiddleware(BaseHTTPMiddleware):
def __init__(
self,
app: Callable[[Request], Awaitable[Response]],
config: SecurityConfig
):
# ... initialization
Methods¶
dispatch¶
async def dispatch(
self,
request: Request,
call_next: Callable[[Request], Awaitable[Response]]
) -> Response:
"""
Main method that processes each request through
the security pipeline.
"""
create_error_response¶
async def create_error_response(
self,
status_code: int,
default_message: str
) -> Response:
"""
Creates standardized error responses.
"""