1.

What are the default authentication methods available in Django?

Answer»

By default there are four MAIN authentication methods are available -

1. SessionAuthentication - This authentication scheme uses Django's default session backend for authentication and it is appropriate for AJAX clients that are RUNNING in the same session context as your website.

If authentication is successful, it provides the following credentials -

  • request.USER - Django User instance.
  • request.auth - none

Unauthenticated responses will result in an HTTP 403 Forbidden response.

2. BasicAuthentication - Basic authentication scheme uses HTTP Basic Authentication that is signed against a user's username and password. BasicAuthentication is appropriate for testing.

If authentication is successful, it provides the following credentials -

  • request.user - Django User instance.
  • request.auth - None

Unauthenticated responses will result in an HTTP 401 Unauthorized response with an appropriate WWW-Authenticate header. 

3. TokenAuthentication - TokenAuthentication scheme uses a simple token-based HTTP authentication scheme and is SUITABLE for client-server setups like native DESKTOP or mobile client.

If authentication is successful, TokenAuthentication provides the following credentials.

  • request.user - a Django User instance.
  • request.auth - a rest_framework.authtoken.models.Token instance.

Unauthenticated responses will result in an HTTP 401 Unauthorized response with an appropriate WWW-Authenticate header.

4. RemoteUserAuthentication - RemoteUserAuthentication scheme allows you to delegate authentication to your web server which sets the REMOTE_USERenvironment variable.

If authentication is successful, RemoteUserAuthentication providese following credentials -

  • request.user - Django User instance.
  • request.auth - None


Discussion

No Comment Found