Skip to content

middleware

FastAPI middleware that delegates authentication to the configured provider.

Classes:

  • AuthMiddleware

    Delegates authentication to the configured provider on every request.

AuthMiddleware

AuthMiddleware(app: ASGIApp, auth_cfg: AuthConfig)

              flowchart TD
              oqtopus_auth.fastapi.middleware.AuthMiddleware[AuthMiddleware]

              

              click oqtopus_auth.fastapi.middleware.AuthMiddleware href "" "oqtopus_auth.fastapi.middleware.AuthMiddleware"
            

Delegates authentication to the configured provider on every request.

Methods:

  • dispatch

    Delegate to the provider and return 403 on AuthenticationError.

dispatch async

dispatch(
    request: Request, call_next: RequestResponseEndpoint
) -> Response

Delegate to the provider and return 403 on AuthenticationError.

Returns:

  • Response

    403 response if the provider raises AuthenticationError; otherwise

  • Response

    the downstream response with request.state.user set.