AuthenticationMiddleware
class¶
This is the reference for the main object AuthenticationMiddleware
that contains all the parameters,
attributes and functions.
This is also the newest way of performing authentication in Ravyn, and it is recommended to use
this class instead of BaseAuthMiddleware
for new projects.
ravyn.middleware.authentication.AuthenticationMiddleware
¶
AuthenticationMiddleware(app, backend=None, on_error=None)
Bases: AuthenticationMiddleware
PARAMETER | DESCRIPTION |
---|---|
app
|
The ASGI application callable wrapped by this middleware.
TYPE:
|
backend
|
One or more authentication backends used to authenticate the connection. If multiple backends are provided, they are tried in order.
TYPE:
|
on_error
|
An optional error handler function called when authentication fails. It receives the Connection and AuthenticationError and must return an ASGI-compatible Response object.
TYPE:
|
Source code in ravyn/middleware/authentication.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
authenticate
async
¶
authenticate(conn)
Authorize users here.
Source code in lilya/middleware/authentication.py
124 125 126 127 128 129 130 131 132 |
|
default_on_error
staticmethod
¶
default_on_error(connection, exc)
Source code in lilya/middleware/authentication.py
99 100 101 |
|