BaseAuthMiddleware
class¶
This is the reference for the main object BaseAuthMiddleware
that contains all the parameters,
attributes and functions.
esmerald.middleware.authentication.BaseAuthMiddleware
¶
BaseAuthMiddleware(app)
Bases: ABC
, MiddlewareProtocol
BaseAuthMiddleware
is the object that you can implement if you
want to implement any authentication
middleware with Esmerald.
It is not mandatory to use it and you are free to implement your.
Esmerald being based on Lilya, also offers a simple but powerful
interface for handling authentication
and permissions.
Once you have installed the AuthenticationMiddleware
and implemented the
authenticate
, the request.user
will be available in any of your
endpoints.
Read more about how Esmerald implements the BaseAuthMiddleware
.
When implementing the authenticate
, you must assign the result into the
AuthResult
object in order for the middleware to assign the request.user
properly.
The AuthResult
is of type esmerald.middleware.authentication.AuthResult
.
PARAMETER | DESCRIPTION |
---|---|
app
|
An ASGI type callable.
TYPE:
|
Source code in esmerald/middleware/authentication.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
authenticate
abstractmethod
async
¶
authenticate(request)
The abstract method that needs to be implemented for any authentication middleware.
PARAMETER | DESCRIPTION |
---|---|
request
|
TYPE:
|
Source code in esmerald/middleware/authentication.py
77 78 79 80 81 82 |
|