Learning about the authentication classes
The Django REST framework provides the following three authentication classes in the rest_framework.authentication
module. All of them are subclasses of the BaseAuthentication
class:
BasicAuthentication
: This class provides an HTTP basic authentication against a username and a password.SessionAuthentication
: This class works with Django's session framework for authentication.TokenAuthentication
: This class provides a simple token-based authentication. The request must include the token generated for a user as the value for theAuthorization
HTTP header key with the'Token '
string as a prefix for the token.
Note
Of course, in a production environment, we must make sure that the RESTful Web Service is only available over HTTPS, with the usage of the latest TLS versions. We shouldn't use an HTTP basic authentication or a simple token-based authentication over plain HTTP in a production environment.
The previous classes are included in the Django REST framework...