authentication¶
- class litestar.middleware.authentication.AbstractAuthenticationMiddleware[源代码]¶
基类:
ABCAbstract AuthenticationMiddleware that allows users to create their own AuthenticationMiddleware by extending it and overriding
AbstractAuthenticationMiddleware.authenticate_request().- __init__(app: ASGIApp, exclude: str | list[str] | None = None, exclude_from_auth_key: str = 'exclude_from_auth', exclude_http_methods: Sequence[Method] | None = None, scopes: Scopes | None = None) None[源代码]¶
Initialize
AbstractAuthenticationMiddleware.- 参数:
app¶ -- An ASGIApp, this value is the next ASGI handler to call in the middleware stack.
exclude¶ -- A pattern or list of patterns to skip in the authentication middleware.
exclude_from_auth_key¶ -- An identifier to use on routes to disable authentication for a particular route.
exclude_http_methods¶ -- A sequence of http methods that do not require authentication.
scopes¶ -- ASGI scopes processed by the authentication middleware.
- abstractmethod async authenticate_request(connection: ASGIConnection) AuthenticationResult[源代码]¶
Receive the http connection and return an
AuthenticationResult.备注
This method must be overridden by subclasses.
- 参数:
connection¶ -- An
ASGIConnectioninstance.- 抛出:
NotAuthorizedException | PermissionDeniedException -- if authentication fails.
- 返回:
An instance of
AuthenticationResult.